当前位置: 首页>>代码示例>>Java>>正文


Java Protocol类代码示例

本文整理汇总了Java中com.googlecode.vfsjfilechooser2.accessories.connection.Protocol的典型用法代码示例。如果您正苦于以下问题:Java Protocol类的具体用法?Java Protocol怎么用?Java Protocol使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Protocol类属于com.googlecode.vfsjfilechooser2.accessories.connection包,在下文中一共展示了Protocol类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: selectPortNumber

import com.googlecode.vfsjfilechooser2.accessories.connection.Protocol; //导入依赖的package包/类
private void selectPortNumber() {
	// Go and get default port number according to the selected protocol
	Protocol protocol = (Protocol) protocolList.getSelectedItem();

	if (protocol.toString().equals("FILE")) {
		enableFields(false);

		this.isPortTextFieldDirty = false;

		return;
	} else {
		enableFields(true);
	}

	// if user types in a port number
	// or empties port number field
	// then do not set protocol's default port number
	if (isPortTextFieldDirty() && portTextField.isEditValid()) {
		return;
	}

	portTextField.setValue(protocol.getPort());
}
 
开发者ID:fracpete,项目名称:vfsjfilechooser2,代码行数:24,代码来源:BookmarksEditorPanel.java

示例2: getListCellRendererComponent

import com.googlecode.vfsjfilechooser2.accessories.connection.Protocol; //导入依赖的package包/类
@Override
public Component getListCellRendererComponent(JList list, Object value,
		int index, boolean isSelected, boolean cellHasFocus) {
	if (isSelected) {
		setBackground(list.getSelectionBackground());
		setForeground(list.getSelectionForeground());

		if (-1 < index) {
			Protocol aProtocol = (Protocol) value;
			list.setToolTipText(aProtocol.getDescription());
		}
	} else {
		setBackground(list.getBackground());
		setForeground(list.getForeground());
	}

	setFont(list.getFont());
	setText((value == null) ? "" : value.toString());

	return this;
}
 
开发者ID:fracpete,项目名称:vfsjfilechooser2,代码行数:22,代码来源:BookmarksEditorPanel.java

示例3: selectPortNumber

import com.googlecode.vfsjfilechooser2.accessories.connection.Protocol; //导入依赖的package包/类
private void selectPortNumber() {
      // Go and get default port number according to the selected protocol
      Protocol protocol = (Protocol) protocolList.getSelectedItem();

      if (protocol.toString().equals("FILE")) {
          enableFields(false);

          this.isPortTextFieldDirty = false;

          return;
      } else {
          enableFields(true);
      }

// if user types in a port number
      // or empties port number field
      // then do not set protocol's default port number
      if (isPortTextFieldDirty() && portTextField.isEditValid()) {
          return;
      }

      portTextField.setValue(protocol.getPort());
  }
 
开发者ID:shevek,项目名称:vfsjfilechooser,代码行数:24,代码来源:BookmarksEditorPanel.java

示例4: getListCellRendererComponent

import com.googlecode.vfsjfilechooser2.accessories.connection.Protocol; //导入依赖的package包/类
@Override
public Component getListCellRendererComponent(JList list, Object value,
        int index, boolean isSelected, boolean cellHasFocus) {
    if (isSelected) {
        setBackground(list.getSelectionBackground());
        setForeground(list.getSelectionForeground());

        if (-1 < index) {
            Protocol aProtocol = (Protocol) value;
            list.setToolTipText(aProtocol.getDescription());
        }
    } else {
        setBackground(list.getBackground());
        setForeground(list.getForeground());
    }

    setFont(list.getFont());
    setText((value == null) ? "" : value.toString());

    return this;
}
 
开发者ID:shevek,项目名称:vfsjfilechooser,代码行数:22,代码来源:BookmarksEditorPanel.java

示例5: testParseLocalFiles

import com.googlecode.vfsjfilechooser2.accessories.connection.Protocol; //导入依赖的package包/类
/**
 * Parsing local files
 */
public void testParseLocalFiles() {
    logger.info("Testing VFSURIParser for local files\n");

    // testing local files
    VFSURIParser parser;

    parser = new VFSURIParser("file:///C:/home/birdman");
    assertEquals(Protocol.FILE, parser.getProtocol());
    assertEquals("C:/home/birdman", parser.getPath());
    assertNull(parser.getHostname());
    assertNull(parser.getPortnumber());
    assertNull(parser.getUsername());
    assertNull(parser.getPassword());

    parser = new VFSURIParser("file:///home/birdman");
    assertEquals(Protocol.FILE, parser.getProtocol());
    assertEquals("/home/birdman", parser.getPath());
    assertNull(parser.getHostname());
    assertNull(parser.getPortnumber());
    assertNull(parser.getUsername());
    assertNull(parser.getPassword());

}
 
开发者ID:shevek,项目名称:vfsjfilechooser,代码行数:27,代码来源:VFSURIParserTest.java

示例6: VFSURIParser

import com.googlecode.vfsjfilechooser2.accessories.connection.Protocol; //导入依赖的package包/类
public VFSURIParser(final String fileURI, boolean assignDefaultPort) {
	if (fileURI == null) {
		throw new NullPointerException("file URI is null");
	}
	
	VFSURIValidator v = new VFSURIValidator();
	boolean valid = v.isValid(fileURI);
	if (valid) {
		hostname = v.getHostname();
		username = v.getUser();
		password = v.getPassword();
		path = v.getFile();
		portnumber = v.getPort();
		String p = v.getProtocol();
		
		//fix up parsing results
		protocol = Protocol.valueOf(p.toUpperCase());
		if ((portnumber == null) && (!p.equalsIgnoreCase("file"))) {
			portnumber = String.valueOf(protocol.getPort());
		}
		if (path == null) {
			path = String.valueOf(PATH_SEPARATOR);
		}
	} else {
		hostname = null;
		username = null;
		password = null;
		path = fileURI;
		portnumber = null;
		protocol = null;
	}

}
 
开发者ID:fracpete,项目名称:vfsjfilechooser2,代码行数:34,代码来源:VFSURIParser.java

示例7: resetFields

import com.googlecode.vfsjfilechooser2.accessories.connection.Protocol; //导入依赖的package包/类
private void resetFields() {
	this.isPortTextFieldDirty = false;
	bookmarkNameTextField.setText("");
	hostnameTextField.setText("");
	protocolList.setSelectedItem(Protocol.FTP);
	usernameTextField.setText("");
	passwordTextField.setText("");
	defaultRemotePathTextField.setText("");
}
 
开发者ID:fracpete,项目名称:vfsjfilechooser2,代码行数:10,代码来源:BookmarksEditorPanel.java

示例8: VFSURIParser

import com.googlecode.vfsjfilechooser2.accessories.connection.Protocol; //导入依赖的package包/类
public VFSURIParser(final String fileURI, boolean assignDefaultPort) {
    if (fileURI == null) {
        throw new NullPointerException("file URI is null");
    }

    VFSURIValidator v = new VFSURIValidator();
    boolean valid = v.isValid(fileURI);
    if (valid) {
        hostname = v.getHostname();
        username = v.getUser();
        password = v.getPassword();
        path = v.getFile();
        portnumber = v.getPort();
        String p = v.getProtocol();

        //fix up parsing results
        protocol = Protocol.valueOf(p.toUpperCase());
        if ((portnumber == null) && (!p.equalsIgnoreCase("file"))) {
            portnumber = String.valueOf(protocol.getPort());
        }
        if (path == null) {
            path = String.valueOf(PATH_SEPARATOR);
        }
    } else {
        hostname = null;
        username = null;
        password = null;
        path = fileURI;
        portnumber = null;
        protocol = null;
    }

}
 
开发者ID:shevek,项目名称:vfsjfilechooser,代码行数:34,代码来源:VFSURIParser.java

示例9: resetFields

import com.googlecode.vfsjfilechooser2.accessories.connection.Protocol; //导入依赖的package包/类
private void resetFields() {
    this.isPortTextFieldDirty = false;
    bookmarkNameTextField.setText("");
    hostnameTextField.setText("");
    protocolList.setSelectedItem(Protocol.FTP);
    usernameTextField.setText("");
    passwordTextField.setText("");
    defaultRemotePathTextField.setText("");
}
 
开发者ID:shevek,项目名称:vfsjfilechooser,代码行数:10,代码来源:BookmarksEditorPanel.java

示例10: updateFields

import com.googlecode.vfsjfilechooser2.accessories.connection.Protocol; //导入依赖的package包/类
private void updateFields() {
	if (editIndex != -1) {
		TitledURLEntry tue = bookmarks.getEntry(editIndex);
		bookmarkNameTextField.setText(tue.getTitle());
	
	 	//sl start		
		VFSURIValidator v = new VFSURIValidator();
		if(! v.isValid(tue.getURL())){
			//popup a warning 
			JOptionPane.showMessageDialog(null,VFSResources.getMessage("VFSFileChooser.errBADURI"));
		}
	 	//sl stop		

		VFSURIParser parser = new VFSURIParser(tue.getURL(),
				!isPortTextFieldDirty());

		protocolList.setSelectedItem(parser.getProtocol());

		if (parser.getProtocol() != Protocol.FILE) {
			hostnameTextField.setText(parser.getHostname());

			if (parser.getPortnumber() != null
					&& parser.getPortnumber().length() > 0) {
				int test_port = -1;
				try{					//stan
					test_port = Integer.valueOf(parser.getPortnumber());
					portTextField.setValue(test_port);
				}
				catch (Exception ex){
					portTextField.setValue(null);
				}
				if( (test_port<0) || (test_port>65535)){                       //stan
					portTextField.setValue(null);
				}
			} else {
				portTextField.setValue(null);
			}

			if (parser.getUsername() != null) {
				usernameTextField.setText(parser.getUsername());
			}

			if (parser.getPassword() != null) {
				passwordTextField.setText(parser.getPassword());
			}
		}

		defaultRemotePathTextField.setText(parser.getPath());
	}
}
 
开发者ID:fracpete,项目名称:vfsjfilechooser2,代码行数:51,代码来源:BookmarksEditorPanel.java

示例11: initCenterPanelComponents

import com.googlecode.vfsjfilechooser2.accessories.connection.Protocol; //导入依赖的package包/类
private void initCenterPanelComponents() {
	// create the panel
	this.centerPanel = new JPanel(new GridBagLayout());
	this.centerPanel.setBorder(BorderFactory.createEmptyBorder(3, 3, 3, 3));

	JLabel bookmarkNameLabel = new JLabel(VFSResources
			.getMessage("VFSJFileChooser.fileNameHeaderText"));
	this.bookmarkNameTextField = new JTextField(25);

	// create the components
	this.hostnameLabel = new JLabel(VFSResources
			.getMessage("VFSJFileChooser.hostnameLabelText"));
	this.hostnameLabel.setForeground(Color.RED);
	this.hostnameTextField = new JTextField(25);

	this.portLabel = new JLabel(VFSResources
			.getMessage("VFSJFileChooser.portLabelText"));
	this.portTextField = new JFormattedTextField(NumberFormat.getInstance());
	this.isPortTextFieldDirty = false;

	JLabel protocolLabel = new JLabel(VFSResources
			.getMessage("VFSJFileChooser.protocolLabelText"));
	DefaultComboBoxModel protocolModel = new DefaultComboBoxModel(Protocol
			.values());
	this.protocolList = new JComboBox(protocolModel);
	this.protocolList.setRenderer(new ProtocolRenderer());

	this.usernameLabel = new JLabel(VFSResources
			.getMessage("VFSJFileChooser.usernameLabelText"));
	this.usernameTextField = new JTextField(20);

	this.passwordLabel = new JLabel(VFSResources
			.getMessage("VFSJFileChooser.passwordLabelText"));
	this.passwordTextField = new JPasswordField(12);

	JLabel defaultRemotePathLabel = new JLabel(VFSResources
			.getMessage("VFSJFileChooser.pathLabelText"));
	this.defaultRemotePathTextField = new JTextField(20);

	// Add the components to the panel
	makeGridPanel(new Component[] { bookmarkNameLabel,
			bookmarkNameTextField, hostnameLabel, hostnameTextField,
			portLabel, portTextField, protocolLabel, protocolList,
			usernameLabel, usernameTextField, passwordLabel,
			passwordTextField, defaultRemotePathLabel,
			defaultRemotePathTextField });

	// add the usual right click popup menu(copy, paste, etc.)
	PopupHandler.installDefaultMouseListener(bookmarkNameTextField);
	PopupHandler.installDefaultMouseListener(hostnameTextField);
	PopupHandler.installDefaultMouseListener(portTextField);
	PopupHandler.installDefaultMouseListener(usernameTextField);
	PopupHandler.installDefaultMouseListener(passwordTextField);
	PopupHandler.installDefaultMouseListener(defaultRemotePathTextField);
}
 
开发者ID:fracpete,项目名称:vfsjfilechooser2,代码行数:56,代码来源:BookmarksEditorPanel.java

示例12: updateFields

import com.googlecode.vfsjfilechooser2.accessories.connection.Protocol; //导入依赖的package包/类
private void updateFields() {
    if (editIndex != -1) {
        TitledURLEntry tue = bookmarks.getEntry(editIndex);
        bookmarkNameTextField.setText(tue.getTitle());

        //sl start		
        VFSURIValidator v = new VFSURIValidator();
        if (!v.isValid(tue.getURL())) {
            //popup a warning 
            JOptionPane.showMessageDialog(null, VFSResources.getMessage("VFSFileChooser.errBADURI"));
        }
        //sl stop		

        VFSURIParser parser = new VFSURIParser(tue.getURL(),
                !isPortTextFieldDirty());

        protocolList.setSelectedItem(parser.getProtocol());

        if (parser.getProtocol() != Protocol.FILE) {
            hostnameTextField.setText(parser.getHostname());

            if (parser.getPortnumber() != null
                    && parser.getPortnumber().length() > 0) {
                int test_port = -1;
                try {					//stan
                    test_port = Integer.valueOf(parser.getPortnumber());
                    portTextField.setValue(test_port);
                } catch (Exception ex) {
                    portTextField.setValue(null);
                }
                if ((test_port < 0) || (test_port > 65535)) {                       //stan
                    portTextField.setValue(null);
                }
            } else {
                portTextField.setValue(null);
            }

            if (parser.getUsername() != null) {
                usernameTextField.setText(parser.getUsername());
            }

            if (parser.getPassword() != null) {
                passwordTextField.setText(parser.getPassword());
            }
        }

        defaultRemotePathTextField.setText(parser.getPath());
    }
}
 
开发者ID:shevek,项目名称:vfsjfilechooser,代码行数:50,代码来源:BookmarksEditorPanel.java

示例13: initCenterPanelComponents

import com.googlecode.vfsjfilechooser2.accessories.connection.Protocol; //导入依赖的package包/类
private void initCenterPanelComponents() {
    // create the panel
    this.centerPanel = new JPanel(new GridBagLayout());
    this.centerPanel.setBorder(BorderFactory.createEmptyBorder(3, 3, 3, 3));

    JLabel bookmarkNameLabel = new JLabel(VFSResources
            .getMessage("VFSJFileChooser.fileNameHeaderText"));
    this.bookmarkNameTextField = new JTextField(25);

    // create the components
    this.hostnameLabel = new JLabel(VFSResources
            .getMessage("VFSJFileChooser.hostnameLabelText"));
    this.hostnameLabel.setForeground(Color.RED);
    this.hostnameTextField = new JTextField(25);

    this.portLabel = new JLabel(VFSResources
            .getMessage("VFSJFileChooser.portLabelText"));
    this.portTextField = new JFormattedTextField(NumberFormat.getInstance());
    this.isPortTextFieldDirty = false;

    JLabel protocolLabel = new JLabel(VFSResources
            .getMessage("VFSJFileChooser.protocolLabelText"));
    DefaultComboBoxModel protocolModel = new DefaultComboBoxModel(Protocol
            .values());
    this.protocolList = new JComboBox(protocolModel);
    this.protocolList.setRenderer(new ProtocolRenderer());

    this.usernameLabel = new JLabel(VFSResources
            .getMessage("VFSJFileChooser.usernameLabelText"));
    this.usernameTextField = new JTextField(20);

    this.passwordLabel = new JLabel(VFSResources
            .getMessage("VFSJFileChooser.passwordLabelText"));
    this.passwordTextField = new JPasswordField(12);

    JLabel defaultRemotePathLabel = new JLabel(VFSResources
            .getMessage("VFSJFileChooser.pathLabelText"));
    this.defaultRemotePathTextField = new JTextField(20);

    // Add the components to the panel
    makeGridPanel(new Component[]{bookmarkNameLabel,
        bookmarkNameTextField, hostnameLabel, hostnameTextField,
        portLabel, portTextField, protocolLabel, protocolList,
        usernameLabel, usernameTextField, passwordLabel,
        passwordTextField, defaultRemotePathLabel,
        defaultRemotePathTextField});

    // add the usual right click popup menu(copy, paste, etc.)
    PopupHandler.installDefaultMouseListener(bookmarkNameTextField);
    PopupHandler.installDefaultMouseListener(hostnameTextField);
    PopupHandler.installDefaultMouseListener(portTextField);
    PopupHandler.installDefaultMouseListener(usernameTextField);
    PopupHandler.installDefaultMouseListener(passwordTextField);
    PopupHandler.installDefaultMouseListener(defaultRemotePathTextField);
}
 
开发者ID:shevek,项目名称:vfsjfilechooser,代码行数:56,代码来源:BookmarksEditorPanel.java

示例14: testParseCustomPort

import com.googlecode.vfsjfilechooser2.accessories.connection.Protocol; //导入依赖的package包/类
/**
 * parsing with a custom port number
 */
public void testParseCustomPort() {
    logger.info("Testing VFSURIParser for remote files(custom port)\n");

    VFSURIParser parser;

    // test without username,password and path (custom port)
    parser = new VFSURIParser("sftp://shell.sf.net:28");
    assertEquals(Protocol.SFTP, parser.getProtocol());
    assertEquals("/", parser.getPath());
    assertEquals("shell.sf.net", parser.getHostname());
    assertEquals("28", parser.getPortnumber());
    assertNull(parser.getUsername());
    assertNull(parser.getPassword());

    // test without username and password (custom port)
    parser = new VFSURIParser("sftp://shell.sf.net:28/");
    assertEquals(Protocol.SFTP, parser.getProtocol());
    assertEquals("/", parser.getPath());
    assertEquals("shell.sf.net", parser.getHostname());
    assertEquals("28", parser.getPortnumber());
    assertNull(parser.getUsername());
    assertNull(parser.getPassword());

    // test without username and password (custom port)
    parser = new VFSURIParser("sftp://shell.sf.net:28/home/yves");
    assertEquals(Protocol.SFTP, parser.getProtocol());
    assertEquals("/home/yves", parser.getPath());
    assertEquals("shell.sf.net", parser.getHostname());
    assertEquals("28", parser.getPortnumber());
    assertNull(parser.getUsername());
    assertNull(parser.getPassword());

    // test with common values but no password and no path specified
    parser = new VFSURIParser("sftp://[email protected]:28");
    assertEquals(Protocol.SFTP, parser.getProtocol());
    assertEquals("/", parser.getPath());
    assertEquals("shell.sf.net", parser.getHostname());
    assertEquals("28", parser.getPortnumber());
    assertEquals("yves", parser.getUsername());
    assertNull(parser.getPassword());

    // test with common values and the root filesystem path
    parser = new VFSURIParser("sftp://yves:[email protected]:28/");
    assertEquals(Protocol.SFTP, parser.getProtocol());
    assertEquals("/", parser.getPath());
    assertEquals("shell.sf.net", parser.getHostname());
    assertEquals("28", parser.getPortnumber());
    assertEquals("yves", parser.getUsername());
    assertEquals("yves", parser.getPassword());

    // test with common values but no password
    parser = new VFSURIParser("sftp://[email protected]:28/home/yves");
    assertEquals(Protocol.SFTP, parser.getProtocol());
    assertEquals("/home/yves", parser.getPath());
    assertEquals("shell.sf.net", parser.getHostname());
    assertEquals("28", parser.getPortnumber());
    assertEquals("yves", parser.getUsername());
    assertNull(parser.getPassword());

    // test with what the usual uri
    parser = new VFSURIParser("sftp://yves:[email protected]:28/home/yves");
    assertEquals(Protocol.SFTP, parser.getProtocol());
    assertEquals("/home/yves", parser.getPath());
    assertEquals("shell.sf.net", parser.getHostname());
    assertEquals("28", parser.getPortnumber());
    assertEquals("yves", parser.getUsername());
    assertEquals("yves", parser.getPassword());
}
 
开发者ID:shevek,项目名称:vfsjfilechooser,代码行数:72,代码来源:VFSURIParserTest.java

示例15: getProtocol

import com.googlecode.vfsjfilechooser2.accessories.connection.Protocol; //导入依赖的package包/类
/**
 * Returns the VFS protocol
 * @return the VFS protocol
 */
public Protocol getProtocol() {
	return protocol;
}
 
开发者ID:fracpete,项目名称:vfsjfilechooser2,代码行数:8,代码来源:VFSURIParser.java


注:本文中的com.googlecode.vfsjfilechooser2.accessories.connection.Protocol类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。