⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 companyeditwindow.java

📁 发泄网! 发泄网! 发泄网! 发泄网! 发泄网! 发泄网! 发泄网! 发泄网!
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
			bodyPanel.add(textPostcode,				new GridBagConstraints(3, 5, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, defaultInsets, 0, 0));		*/				bodyPanel.add(new JLabel("Industry"),				new GridBagConstraints(0, 6, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, defaultInsets, 0, 0));			bodyPanel.add(companyIdentifier,				new GridBagConstraints(1, 6,  1, 1, 1.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, defaultInsets, 0, 0));				bodyPanel.add(new JLabel("Size"),				new GridBagConstraints(2, 6, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, defaultInsets, 0, 0));			bodyPanel.add(companySize,				new GridBagConstraints(3, 6, 1, 1, 1.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL,  defaultInsets, 0, 0));				bodyPanel.add(new JLabel("ABN"),				new GridBagConstraints(0, 7, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, defaultInsets, 0, 0));			bodyPanel.add(mtextABN,				new GridBagConstraints(1, 7, 1, 1, 1.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, defaultInsets, 0, 0));				bodyPanel.add(new JLabel("ACN"),				new GridBagConstraints(2, 7, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, defaultInsets, 0, 0));			bodyPanel.add(mtextACN,				new GridBagConstraints(3, 7, 1, 1, 1.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, defaultInsets, 0, 0));				bodyPanel.add(new JLabel("Email"),				new GridBagConstraints(0, 8, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, defaultInsets, 0, 0));			bodyPanel.add(mtextEmail,				new GridBagConstraints(1, 8, 1, 1, 1.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, defaultInsets, 0, 0));				bodyPanel.add(new JLabel("URL"),				new GridBagConstraints(2, 8, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, defaultInsets, 0, 0));			bodyPanel.add(mtextURL,				new GridBagConstraints(3, 8, 1, 1, 1.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, defaultInsets, 0, 0));				bodyPanel.add(new JLabel("Profile"),				new GridBagConstraints(0, 9, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHEAST, GridBagConstraints.NONE, defaultInsets, 0, 0));			bodyPanel.add(descScrollPane,				new GridBagConstraints(1, 9, 3, 1, 1.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, defaultInsets, 0, 45));				JPanel main = new JPanel();			main.setLayout(new BoxLayout(main, BoxLayout.Y_AXIS));			main.add(bodyPanel);			main.add(locationComponent);							JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT));			buttonPanel.setBackground(Color.WHITE);				buttonPanel.add(buttonAdd);			buttonPanel.add(buttonReset);			buttonPanel.add(buttonDelete);			buttonPanel.add(buttonCancel);				/*if (panelType != PANEL_TYPE_ADD) {				getContentPane().add(utilityToolbar, BorderLayout.NORTH);			}*/			getContentPane().add(main, BorderLayout.CENTER);			getContentPane().add(buttonPanel, BorderLayout.SOUTH);						resetFields();			securePanel();		}	}		public void resetFields() {		// fields that will be set always		if (company.getState() != null) comboState.setSelectedItem(company.getState());		CompanySizeCode csc = company.getCompanySize();		if (csc != null) {			companySize.setSelectedItem(CompanySizeCode.getForCode(csc.getCode()));		} else {			companySize.setSelectedItem(CompanySizeCode.SMALL);		}		CompanyIdentifiersTypeCode citc = company.getCompanyType();		if (citc != null) {			companyIdentifier.setSelectedItem(CompanyIdentifiersTypeCode.getForCode(citc.getCode()));		} else {			companyIdentifier.setSelectedItem(CompanyIdentifiersTypeCode.OTHER);		}		if (company.getCompanyName() == null) return;		locationComponent.setLocations(company.getLocations());		textName.setText(company.getCompanyName());		textPhone.setText(company.getPhone());		textFax.setText(company.getFax());		textAddress.setText(company.getAddress());		textSuburb.setText(company.getSuburb());		textCountry.setText(company.getCountry());		textPostcode.setText(company.getPostcode());		mtextABN.setValues(company.getABN());		mtextACN.setValues(company.getACN());		mtextURL.setValues(company.getURL());		mtextEmail.setValues(company.getEmail());		textDesc.setText(company.getNotes());	}		public void securePanel() {				if (entityPermission != null && !entityPermission.canWrite()) {			textName.setEditable(false);			textPhone.setEditable(false);			textFax.setEditable(false);			textAddress.setEditable(false);			textSuburb.setEditable(false);			comboState.setEnabled(false);			textPostcode.setEditable(false);			mtextABN.setEditable(false);			mtextACN.setEditable(false);			mtextURL.setEditable(false);			mtextEmail.setEditable(false);			textCountry.setEditable(false);			textDesc.setEditable(false);			companySize.setEnabled(false);			companyIdentifier.setEnabled(false);			buttonAdd.setVisible(false);			buttonReset.setVisible(false);		}				if (entityPermission != null && entityPermission.canDelete() && companyID > -1) {			buttonDelete.setVisible(true);		} else {			buttonDelete.setVisible(false);   		}			}		public void deleteCompany() {		if (CompanyModuleWrapper.deleteCompany(company.getCompanyID())) {			dispose();		}	}		public void updateCompany() {		locationComponent.updateLocation();				ServerCommand command = null;				if (panelType != PANEL_TYPE_EDIT) {			command = new ServerCommand(CompanyModule.COMPANY_ADD_SUBMIT);		} else {			command = new ServerCommand(CompanyModule.COMPANY_EDIT_SUBMIT);			command.setParameter(CompanyModule.PARAM_COMPANY_ID, String.valueOf(companyID));		}				/*		command.setParameter(CompanyModule.PARAM_COMPANY_PHONE, textPhone.getText());		command.setParameter(CompanyModule.PARAM_COMPANY_FAX, textFax.getText());		command.setParameter(CompanyModule.PARAM_COMPANY_ADDRESS, textAddress.getText());		command.setParameter(CompanyModule.PARAM_COMPANY_SUBURB, textSuburb.getText());		command.setParameter(CompanyModule.PARAM_COMPANY_COUNTRY, textCountry.getText());		command.setParameter(CompanyModule.PARAM_COMPANY_STATE, comboState.getSelectedItem());		command.setParameter(CompanyModule.PARAM_COMPANY_POSTCODE, textPostcode.getText());		*/				command.setParameter(CompanyModule.PARAM_COMPANY_NAME, textName.getText());		CompanyIdentifiersTypeCode type  = (CompanyIdentifiersTypeCode)companyIdentifierModel.getSelectedItem();	   	command.setParameter(CompanyModule.PARAM_COMPANY_TYPE,type);	   			CompanySizeCode size  = (CompanySizeCode)companySizeModel.getSelectedItem();		command.setParameter(CompanyModule.PARAM_COMPANY_SIZE,size);				command.setParameter(CompanyModule.PARAM_COMPANY_ABN, mtextABN.getValues());		command.setParameter(CompanyModule.PARAM_COMPANY_ACN, mtextACN.getValues());		command.setParameter(CompanyModule.PARAM_COMPANY_URL, mtextURL.getValues());		command.setParameter(CompanyModule.PARAM_COMPANY_EMAIL, mtextEmail.getValues());		command.setParameter(CompanyModule.PARAM_COMPANY_NOTES, textDesc.getText());		command.setParameter(CompanyModule.PARAM_COMPANY_LOCATIONS, locationComponent.getLocations());				Server server = ServerFactory.getInstance().getServer();				ServerResponse sr = server.sendCommand(command);		if (sr != null) {			company = (Company)sr.getPart("company");		}	}	/** @return True if it is ok to add */	public boolean checkDuplicates() {		/* TODO: COMPANY_SEARCH looks for a case insensitive *name* meaning if there is a company		 * 			All Computer Supplies Pty Ltd		 * and you are looking for		 * 			Computer Supplies		 * then it will match.		 */		ServerCommand command = new ServerCommand(CompanyModule.COMPANY_EXISTS);		command.setParameter(CompanyModule.PARAM_COMPANY_NAME, textName.getText());		Server server = ServerFactory.getInstance().getServer();		ServerResponse sr = server.sendCommand(command);		return sr != null && sr.getPart("exists") != null;	}		public boolean validateForm() {		StringBuffer buf = new StringBuffer();		boolean valid = true;		if (textName.getText().trim().equals("")) {			valid = false;			buf.append( "- You must fill in the company name.\n");		} else {			boolean duplicate = checkDuplicates();			// only check for duplicates if the name is set			if (duplicate &&  panelType == PANEL_TYPE_ADD) {				valid = false;				buf.append("- The company with name: ");				buf.append(textName.getText());				buf.append(" was already found in the database.  Please check the company list and/or correct the company name.\n");			} 		}		if (!valid) {			buf.insert(0, "There were errors on the form you have submitted:\n\n");			buf.append("\n");			JOptionPane.showMessageDialog(this, buf.toString(),"Invalid Form Data", JOptionPane.ERROR_MESSAGE);		}				return valid;	}	// COMPANY SEARCHER INTERFACE	public void setCompanyFound(Company company, Object object) {		this.panelType = PANEL_TYPE_EDIT;		this.companyID = company.getCompanyID();	}	public void cancelCompanySearch(Object object) {		// do nothing	}	public void display() {		init();		setVisible(true);	}	public void callback(Object source, int mode, Object data) {	}		/**	 * Main class	 *	 * @param args	 */	public static void main(String[] args) {		CompanyEditWindow window = new CompanyEditWindow();		window.display();	}}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -