|
What this is
Other links
The source code
/*
* Sun Public License Notice
*
* The contents of this file are subject to the Sun Public License
* Version 1.0 (the "License"). You may not use this file except in
* compliance with the License. A copy of the License is available at
* http://www.sun.com/
*
* The Original Code is NetBeans. The Initial Developer of the Original
* Code is Sun Microsystems, Inc. Portions Copyright 1997-2000 Sun
* Microsystems, Inc. All Rights Reserved.
*/
package org.netbeans.modules.cvsclient.customizer;
/**
*
* @author Milos Kleint
*/
import java.beans.*;
import javax.swing.event.ChangeListener;
import org.openide.util.NbBundle;
import org.openide.*;
import org.netbeans.modules.cvsclient.NbJavaCvsFileSystem;
import java.awt.event.*;
import java.awt.*;
import java.io.*;
import javax.swing.*;
import javax.swing.border.*;
import javax.swing.event.*;
import javax.accessibility.*;
public class NbJavaCvsCustomizer extends javax.swing.JPanel
implements java.beans.Customizer, java.beans.PropertyChangeListener {
private NbJavaCvsFileSystem fileSystem;
private WizardDescriptor.Panel workpanel;
private WizardDescriptor.Panel serverpanel;
private WizardDescriptor.Panel mountpanel;
private JPanel mountOuterPanel;
private WizardDescriptor.Panel oldPanel = null;
private PropertyChangeSupport changeSupport=null;
private EventListenerList listeners;
private ActionListener closeListener = null;
public String rootValue = ""; // NOI18N
private String serverType;
private String userName;
private String serverName;
private int port;
private String repository;
private File workingDir;
private String relMount;
private boolean backupFiles;
private boolean offLine;
private boolean processAll;
private int autoRefresh;
private int uiMode;
private int displayType;
/** Creates new form NbJavaCvsCustomizer */
public NbJavaCvsCustomizer() {
initComponents();
initAccessibility();
workpanel = new Cust1WorkPanel.Panel (null);
tabProps.add(NbBundle.getBundle(NbJavaCvsCustomizer.class).getString("Customizer.workingDir"), workpanel.getComponent()); // NOI18N
serverpanel = new Cust2ServerPanel.Panel (null);
tabProps.add(NbBundle.getBundle(NbJavaCvsCustomizer.class).getString("Customizer.server"), serverpanel.getComponent()); // NOI18N
mountpanel = new Cust4MountPanel.Panel (null, true);
tabProps.add(NbBundle.getBundle(NbJavaCvsCustomizer.class).getString("Customizer.relMount"), mountpanel.getComponent()); // NOI18N
org.openide.util.HelpCtx.setHelpIDString(this, NbJavaCvsCustomizer.class.getName());
}
/** This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
*/
private void initComponents() {//GEN-BEGIN:initComponents
tabProps = new javax.swing.JTabbedPane();
setLayout(new java.awt.GridBagLayout());
java.awt.GridBagConstraints gridBagConstraints1;
tabProps.addChangeListener(new javax.swing.event.ChangeListener() {
public void stateChanged(javax.swing.event.ChangeEvent evt) {
tabPropsStateChanged(evt);
}
});
gridBagConstraints1 = new java.awt.GridBagConstraints();
gridBagConstraints1.fill = java.awt.GridBagConstraints.BOTH;
gridBagConstraints1.insets = new java.awt.Insets(12, 12, 0, 11);
gridBagConstraints1.weightx = 1.0;
gridBagConstraints1.weighty = 1.0;
add(tabProps, gridBagConstraints1);
}//GEN-END:initComponents
private void tabPropsStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_tabPropsStateChanged
// Add your handling code here:
if (oldPanel != null) {
oldPanel.storeSettings(this);
}
int index = tabProps.getSelectedIndex();
oldPanel = getPanelById (index);
oldPanel.readSettings(this);
}//GEN-LAST:event_tabPropsStateChanged
public void addPropertyChangeListener(java.beans.PropertyChangeListener propertyChangeListener) {
}
public void removePropertyChangeListener(java.beans.PropertyChangeListener propertyChangeListener) {
}
public void setObject(java.lang.Object obj) {
if (obj instanceof NbJavaCvsFileSystem) {
fileSystem = (NbJavaCvsFileSystem)obj;
setServerType(fileSystem.getCvsServerTypeName());
setUserName(fileSystem.getCvsUserName());
setServerName(fileSystem.getCvsServerName());
setRepository(fileSystem.getCvsRepository());
setRelMount(fileSystem.getRelMount());
setWorkingDir(fileSystem.getWorkingDir());
// setHideShadow(fileSystem.isHideShadowFiles());
// setZippedTransfer(fileSystem.isZippedTransfer());
setOffLine(fileSystem.isOffLine());
setAutoRefresh(fileSystem.getAutoRefresh());
setUiMode(fileSystem.getUiMode());
setOutputDisplay(fileSystem.getDisplayType());
setPort(fileSystem.getCvsPort());
setProcessAll(fileSystem.isProcessAllFiles());
setBackups(fileSystem.isCreateBackups());
workpanel.readSettings(this);
}
}
public void propertyChange(java.beans.PropertyChangeEvent propertyChangeEvent) {
}
private static final java.util.ResourceBundle bundle = NbBundle.getBundle(NbJavaCvsCustomizer.class); // NOI18N
private void initAccessibility() {
AccessibleContext context = this.getAccessibleContext();
context.setAccessibleDescription(bundle.getString("ACSD_NbJavaCvsCustomizer"));
context = tabProps.getAccessibleContext();
context.setAccessibleDescription(bundle.getString("ACSD_NbJavaCvsCustomizer.tabProps"));
context.setAccessibleName(bundle.getString("ACSN_NbJavaCvsCustomizer.tabProps"));
}
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JTabbedPane tabProps;
// End of variables declaration//GEN-END:variables
/** Getter for property serverType.
* @return Value of property serverType.
*/
public String getServerType() {
return serverType;
}
/** Setter for property serverType.
* @param serverType New value of property serverType.
*/
public void setServerType(String serverType) {
this.serverType = serverType;
}
/** Getter for property userName.
* @return Value of property userName.
*/
public String getUserName() {
return userName;
}
/** Setter for property userName.
* @param userName New value of property userName.
*/
public void setUserName(String userName) {
this.userName = userName;
}
/** Getter for property serverName.
* @return Value of property serverName.
*/
public String getServerName() {
return serverName;
}
/** Setter for property serverName.
* @param serverName New value of property serverName.
*/
public void setServerName(String serverName) {
this.serverName = serverName;
}
/** Getter for property repository.
* @return Value of property repository.
*/
public String getRepository() {
return repository;
}
/** Setter for property repository.
* @param repository New value of property repository.
*/
public void setRepository(String repository) {
this.repository = repository;
}
/** Getter for property workingDir.
* @return Value of property workingDir.
*/
public File getWorkingDir() {
return workingDir;
}
/** Setter for property workingDir.
* @param workingDir New value of property workingDir.
*/
public void setWorkingDir(File workingDir) {
this.workingDir = workingDir;
}
/** Getter for property relMount.
* @return Value of property relMount.
*/
public String getRelMount() {
return relMount;
}
/** Setter for property relMount.
* @param relMount New value of property relMount.
*/
public void setRelMount(String relMount) {
this.relMount = relMount;
}
public void setOffLine(boolean off) {
offLine = off;
}
public boolean isOffLine() {
return offLine;
}
public void setBackups(boolean hide) {
backupFiles = hide;
}
public boolean isBackups() {
return backupFiles;
}
public void setProcessAll(boolean all) {
this.processAll = all;
}
public boolean isProcessAll() {
return processAll;
}
public void setUiMode(int mode) {
uiMode = mode;
}
public int getUiMode() {
return uiMode;
}
public void setOutputDisplay(int displ) {
displayType = displ;
}
public int getOutputDisplay() {
return displayType;
}
public void setAutoRefresh(int refresh) {
autoRefresh = refresh;
}
public int getAutoRefresh() {
return autoRefresh;
}
public int getPort() {
return port;
}
/** Setter for property relMount.
* @param relMount New value of property relMount.
*/
public void setPort(int newPort) {
port = newPort;
}
/** returns the filesystem passed to the customizer via setObject() method
* @return the currently edited CVS filesystem.
*/
public NbJavaCvsFileSystem getFileSystem() {
return fileSystem;
}
private ActionListener getActionListener() {
return new ActionListener() {
public void actionPerformed(final ActionEvent ev) {
if (ev.getID() == ActionEvent.ACTION_PERFORMED) {
if (NotifyDescriptor.OK_OPTION.equals(ev.getSource())) {
new Thread(new Runnable() { // Do not use RequestProcessor, a deadlock will occure
public void run() {
if (testValidInput()) {
if (closeListener != null) {
javax.swing.SwingUtilities.invokeLater(new Runnable() {
public void run() {
closeListener.actionPerformed(ev);
closeListener = null;
}
});
}
}
}
}).start();
}
}
}
};
}
private void setCloseListener(ActionListener closeListener) {
this.closeListener = closeListener;
}
private boolean testValidInput() {
applyChanges();
/* if (!isLoggedIn()) {
if (loginCancelled) {
//setVisible(true);
return false;
} else {
fileSystem.setOffLine(true); // set offline mode
}
}
*/
// fileSystem.getCacheProvider().refreshDirFromDiskCache(fileSystem.getFile(""));
//org.openide.TopManager.getDefault ().getRepository ().addFileSystem (fileSystem);
return true;
}
private void applyChanges() {
if (oldPanel != null) {
oldPanel.storeSettings(this);
}
fileSystem.setWorkingDir(getWorkingDir());
fileSystem.setRelMount(getRelMount());
fileSystem.setCvsServerType(fileSystem.getCvsServerType(getServerType()));
fileSystem.setCvsServerName(getServerName());
fileSystem.setCvsUserName(getUserName());
fileSystem.setCvsRepository(getRepository());
// fileSystem.setHideShadowFiles(isHideShadow());
fileSystem.setOffLine(isOffLine());
// fileSystem.setZippedTransfer(isZippedTransfer());
fileSystem.setAutoRefresh(getAutoRefresh());
fileSystem.setUiMode(getUiMode());
fileSystem.setDisplayType(getOutputDisplay());
fileSystem.setCvsPort(getPort());
fileSystem.setCreateBackups(isBackups());
fileSystem.setProcessAllFiles(isProcessAll());
}
public static class Dialog extends DialogDescriptor implements Customizer {
private NbJavaCvsCustomizer customizerPanel = null;
public Dialog() {
this(new NbJavaCvsCustomizer(),
org.openide.util.NbBundle.getBundle(NbJavaCvsCustomizer.class).getString("NbJavaCvsCustomizer.title")); // NOI18N
}
public Dialog(NbJavaCvsCustomizer innerPane, String title) {
super(innerPane, title, true, innerPane.getActionListener());
customizerPanel = innerPane;
setClosingOptions(new Object[] { NotifyDescriptor.OK_OPTION, NotifyDescriptor.CANCEL_OPTION });
}
public void setCloseListener(ActionListener closeListener) {
this.customizerPanel.setCloseListener(closeListener);
}
public void setObject(final Object obj) {
// this.fileSystem = (NbJavaCvsFileSystem) obj;
customizerPanel.setObject(obj);
/*
setButtonListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent ev) {
if (ev.getID() == ActionEvent.ACTION_PERFORMED) {
if (NotifyDescriptor.OK_OPTION.equals(ev.getSource())) {
applyChanges();
}
}
}
});
*/
}
}
public static void centerWindow (Window w) {
w.setBounds(org.openide.util.Utilities.findCenterBounds(w.getSize()));
}
private WizardDescriptor.Panel getPanelById (int id) {
switch (id) {
case 0:
return this.workpanel;
case 1:
return this.serverpanel;
case 2:
return this.mountpanel;
default:
throw new IllegalArgumentException ();
}
}
}
|
| ... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
Copyright 1998-2024 Alvin Alexander, alvinalexander.com
All Rights Reserved.
A percentage of advertising revenue from
pages under the /java/jwarehouse
URI on this website is
paid back to open source projects.