Java tutorial
// Copyright 2007 Hitachi Data Systems // All Rights Reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); you may // not use this file except in compliance with the License. You may obtain // a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, WITHOUT // WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the // License for the specific language governing permissions and limitations // under the License. package com.archivas.clienttools.arcmover.gui.settings; import java.awt.*; import javax.swing.*; import com.archivas.clienttools.arcutils.config.HCPMoverConstants; import com.archivas.clienttools.arcutils.config.HCPMoverProperties; import com.jgoodies.forms.layout.CellConstraints; import com.jgoodies.forms.layout.FormLayout; public class ClusterOptionsForm extends JPanel { protected JPanel archiveOptionsTab; protected JRadioButton indexDefaultRadio; protected JRadioButton indexYesRadio; protected JRadioButton indexNoRadio; protected JRadioButton shredDefaultRadio; protected JRadioButton shredYesRadio; protected JRadioButton shredNoRadio; protected JPanel contentPane; protected ButtonGroup indexFileButtonGroup; public ClusterOptionsForm() { loadSettings(); } @Override public void setVisible(final boolean visible) { if (visible) { loadSettings(); } super.setVisible(visible); } public void loadSettings() { setSearchIndexSetting(HCPMoverProperties.INDEX_MODE.getAsTriState()); setShredSetting(HCPMoverProperties.SHRED_MODE.getAsTriState()); } public void applySettingsAction() { HCPMoverProperties.INDEX_MODE.set(getSearchIndexSetting()); HCPMoverProperties.SHRED_MODE.set(getShredSetting()); } public HCPMoverConstants.TriState getSearchIndexSetting() { if (indexYesRadio.isSelected()) { return HCPMoverConstants.TriState.YES; } else if (indexNoRadio.isSelected()) { return HCPMoverConstants.TriState.NO; } else { return HCPMoverConstants.TriState.DEFAULT; } } public void setSearchIndexSetting(final HCPMoverConstants.TriState searchIndexSetting) { switch (searchIndexSetting) { case YES: indexYesRadio.setSelected(true); break; case NO: indexNoRadio.setSelected(true); break; default: indexDefaultRadio.setSelected(true); break; } } public HCPMoverConstants.TriState getShredSetting() { if (shredYesRadio.isSelected()) { return HCPMoverConstants.TriState.YES; } else if (shredNoRadio.isSelected()) { return HCPMoverConstants.TriState.NO; } else { return HCPMoverConstants.TriState.DEFAULT; } } public void setShredSetting(final HCPMoverConstants.TriState shredSetting) { switch (shredSetting) { case YES: shredYesRadio.setSelected(true); break; case NO: shredNoRadio.setSelected(true); break; default: shredDefaultRadio.setSelected(true); break; } } { // GUI initializer generated by IntelliJ IDEA GUI Designer // >>> IMPORTANT!! <<< // DO NOT EDIT OR ADD ANY CODE HERE! $$$setupUI$$$(); } /** * Method generated by IntelliJ IDEA GUI Designer >>> IMPORTANT!! <<< DO NOT edit this method OR * call it in your code! * * @noinspection ALL */ private void $$$setupUI$$$() { contentPane = new JPanel(); contentPane.setLayout(new FormLayout("fill:d:grow", "top:d:grow")); archiveOptionsTab = new JPanel(); archiveOptionsTab.setLayout(new FormLayout( "fill:4dlu:noGrow,fill:129px:noGrow,left:4dlu:noGrow,fill:d:grow,fill:4dlu:noGrow", "center:4dlu:noGrow,center:max(d;4px):noGrow,top:4dlu:noGrow,center:max(d;4px):noGrow,center:max(d;4px):noGrow,center:max(d;4px):noGrow,top:max(m;6dlu):noGrow,center:d:grow,top:6dlu:noGrow,center:max(d;4px):noGrow,top:4dlu:noGrow,center:max(d;4px):noGrow,center:max(d;4px):noGrow,center:26px:noGrow,center:4dlu:grow")); CellConstraints cc = new CellConstraints(); contentPane.add(archiveOptionsTab, cc.xy(1, 1)); indexDefaultRadio = new JRadioButton(); indexDefaultRadio.setSelected(true); indexDefaultRadio.setText("Use Namespace Default"); indexDefaultRadio.setToolTipText("File(s) will be indexed based on namespace's settings"); archiveOptionsTab.add(indexDefaultRadio, cc.xyw(2, 4, 3)); indexYesRadio = new JRadioButton(); indexYesRadio.setText("Yes"); indexYesRadio.setToolTipText("File(s) will be indexed by search engine"); archiveOptionsTab.add(indexYesRadio, cc.xyw(2, 5, 3)); indexNoRadio = new JRadioButton(); indexNoRadio.setText("No"); indexNoRadio.setToolTipText("File(s) will not be indexed by search engine"); archiveOptionsTab.add(indexNoRadio, cc.xyw(2, 6, 3)); final JSeparator separator1 = new JSeparator(); archiveOptionsTab.add(separator1, cc.xyw(2, 8, 3, CellConstraints.FILL, CellConstraints.FILL)); shredDefaultRadio = new JRadioButton(); shredDefaultRadio.setSelected(true); shredDefaultRadio.setText("Use Namespace Default"); shredDefaultRadio.setToolTipText("File(s) will be disposed of based on namespace's settings."); archiveOptionsTab.add(shredDefaultRadio, cc.xyw(2, 12, 3)); shredYesRadio = new JRadioButton(); shredYesRadio.setText("Yes"); shredYesRadio.setToolTipText("Shred file(s) upon delete."); archiveOptionsTab.add(shredYesRadio, cc.xyw(2, 13, 3)); shredNoRadio = new JRadioButton(); shredNoRadio.setText("No"); shredNoRadio.setToolTipText("File(s) will not be shred upon delete."); archiveOptionsTab.add(shredNoRadio, cc.xyw(2, 14, 3)); final JPanel panel1 = new JPanel(); panel1.setLayout( new FormLayout("fill:d:noGrow,left:d:noGrow,left:4dlu:noGrow,left:d:noGrow,fill:max(d;4dlu):grow", "center:d:grow")); archiveOptionsTab.add(panel1, cc.xyw(2, 2, 3)); final JLabel label1 = new JLabel(); label1.setFont(new Font(label1.getFont().getName(), Font.BOLD, 14)); label1.setText("Index Files for Search"); panel1.add(label1, cc.xy(1, 1)); final JLabel label2 = new JLabel(); label2.setText("(only available on HCP 3.0+)"); panel1.add(label2, cc.xy(4, 1)); final JPanel panel2 = new JPanel(); panel2.setLayout( new FormLayout("left:89px:noGrow,fill:4dlu:noGrow,left:max(m;4dlu):grow", "center:d:grow")); archiveOptionsTab.add(panel2, cc.xyw(2, 10, 3)); final JLabel label3 = new JLabel(); label3.setFont(new Font(label3.getFont().getName(), Font.BOLD, 14)); label3.setText("Shred Files on Delete"); panel2.add(label3, cc.xyw(1, 1, 3)); indexFileButtonGroup = new ButtonGroup(); indexFileButtonGroup.add(indexNoRadio); indexFileButtonGroup.add(indexYesRadio); indexFileButtonGroup.add(indexDefaultRadio); ButtonGroup buttonGroup; buttonGroup = new ButtonGroup(); buttonGroup.add(shredDefaultRadio); buttonGroup.add(shredYesRadio); buttonGroup.add(shredNoRadio); } /** * @noinspection ALL */ public JComponent $$$getRootComponent$$$() { return contentPane; } }