Example usage for javax.swing JTabbedPane add

List of usage examples for javax.swing JTabbedPane add

Introduction

In this page you can find the example usage for javax.swing JTabbedPane add.

Prototype

public void add(Component component, Object constraints) 

Source Link

Document

Adds a component to the tabbed pane.

Usage

From source file:ucar.unidata.idv.control.JythonControl.java

/**
 * Make the developer UI contents/*  ww  w.  j  a v a  2  s  .c o  m*/
 * @return  UI for developer code
 */
private JComponent doMakeDeveloperContents() {

    labelFld = new JTextField((myName != null) ? myName : "", 15);
    labelFld.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent ae) {
            setMyName(labelFld.getText().trim());
        }
    });

    Vector probeItems = new Vector();
    for (int i = 0; i < PROBES.length; i++) {
        probeItems.add(new TwoFacedObject(PROBE_NAMES[i], PROBES[i]));
    }
    final JComboBox probeCbx = new JComboBox(probeItems);
    probeCbx.setSelectedItem(new TwoFacedObject(getProbeName(probeType), probeType));
    probeCbx.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent ae) {
            try {
                probeType = ((TwoFacedObject) probeCbx.getSelectedItem()).getId().toString();
                doMakeProbe();
            } catch (Exception exc) {
                logException("Changing probe type", exc);
            }
        }
    });

    displayCategoryFld = new JTextField(jythonDisplayCategory, 15);

    categoriesFld = new JTextArea("", 4, 20);
    if (dataCategories != null) {
        categoriesFld.setText(dataCategories);
    }

    Component[] comps = { GuiUtils.rLabel("Display name: "), GuiUtils.left(labelFld),
            GuiUtils.rLabel("Display Category:"), GuiUtils.left(displayCategoryFld),
            GuiUtils.top(GuiUtils.rLabel("Data Categories:")), GuiUtils.left(new JScrollPane(categoriesFld)),
            GuiUtils.rLabel("Probe Type:"), GuiUtils.left(GuiUtils.hflow(Misc.newList(probeCbx,
                    GuiUtils.rLabel("  Probe Color: "), doMakeColorControl(getColor())))) };

    GuiUtils.tmpInsets = GuiUtils.INSETS_5;
    JPanel fldPanel = GuiUtils.doLayout(comps, 2, GuiUtils.WT_NYN, GuiUtils.WT_N);

    try {
        if (jythonCode == null) {
            jythonCode = IOUtil.readContents("/ucar/unidata/idv/control/jythoncontrol.py", "");
        }

        jythonEditor = new JPythonEditor();
        jythonEditor.setText(jythonCode);
        jythonEditor.setPreferredSize(new Dimension(400, 300));
    } catch (VisADException exc) {
        logException("Creating Jython editor", exc);
    }
    JComponent jythonPanel = new JScrollPane(jythonEditor);
    JTabbedPane tab = GuiUtils.getNestedTabbedPane();
    tab.add("Settings", GuiUtils.top(fldPanel));
    List buttons = Misc.newList(GuiUtils.makeButton("Evaluate Init", this, "execJython", "handleInit"),
            GuiUtils.makeButton("Evaluate Data", this, "execJython", "handleData"));

    JPanel buttonPanel = GuiUtils.left(GuiUtils.hbox(buttons));
    tab.add("Jython", GuiUtils.topCenter(buttonPanel, jythonPanel));
    tab.add("Result GUI", jythonContainer);
    return tab;
}

From source file:fur.shadowdrake.minecraft.InstallPanel.java

private void addonsActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_addonsActionPerformed
    addonsPanel = new AddonsPanel(
            availablePacks.get(modpackChooser.getSelectedIndex()).addons.toArray(new Addon[0]));
    JTabbedPane tabPane;
    tabPane = (JTabbedPane) getParent();
    tabPane.remove(this);
    tabPane.add("Addons", addonsPanel);
    tabPane.setSelectedComponent(addonsPanel);
    addonsOpenedOnce = true;//  w ww.ja  v a 2 s.c  o  m
    parentFrame.setAbortListener((ActionEvent e) -> {
        tabPane.remove(addonsPanel);
        tabPane.add("Install", this);
        tabPane.setSelectedComponent(this);
    });
    parentFrame.setProceedListener((ActionEvent e) -> {
        boolean s[];
        tabPane.remove(addonsPanel);
        tabPane.add("Install", this);
        tabPane.setSelectedComponent(this);
        s = addonsPanel.getSelected();
        for (int n = 0; n < s.length; n++) {
            availablePacks.get(modpackChooser.getSelectedIndex()).addons.get(n).install = s[n];
        }
    });
}

From source file:net.sf.firemox.DeckBuilder.java

/**
 * Creates new form DeckBuilder/*from  ww w .  j  a va 2  s.  com*/
 */
private DeckBuilder() {
    super("DeckBuilder");
    form = this;
    timerPanel = new TimerGlassPane();
    cardLoader = new CardLoader(timerPanel);
    timer = new Timer(200, cardLoader);
    setGlassPane(timerPanel);
    try {
        setIconImage(Picture.loadImage(IdConst.IMAGES_DIR + "deckbuilder.gif"));
    } catch (Exception e) {
        // IGNORING
    }

    // Load settings
    loadSettings();

    // Initialize components
    final JMenuItem newItem = UIHelper.buildMenu("menu_db_new", 'n', this);
    newItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_N, InputEvent.CTRL_MASK));

    final JMenuItem loadItem = UIHelper.buildMenu("menu_db_load", 'o', this);
    loadItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_O, InputEvent.CTRL_MASK));

    final JMenuItem saveAsItem = UIHelper.buildMenu("menu_db_saveas", 'a', this);
    saveAsItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F12, 0));

    final JMenuItem saveItem = UIHelper.buildMenu("menu_db_save", 's', this);
    saveItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S, InputEvent.CTRL_MASK));

    final JMenuItem quitItem = UIHelper.buildMenu("menu_db_exit", this);
    quitItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F4, InputEvent.ALT_MASK));

    final JMenuItem deckConstraintsItem = UIHelper.buildMenu("menu_db_constraints", 'c', this);
    deckConstraintsItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F3, 0));

    final JMenuItem aboutItem = UIHelper.buildMenu("menu_help_about", 'a', this);
    aboutItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F1, InputEvent.SHIFT_MASK));

    final JMenuItem convertDCK = UIHelper.buildMenu("menu_convert_DCK_MP", this);

    final JMenu mainMenu = UIHelper.buildMenu("menu_file");
    mainMenu.add(newItem);
    mainMenu.add(loadItem);
    mainMenu.add(saveAsItem);
    mainMenu.add(saveItem);
    mainMenu.add(new JSeparator());
    mainMenu.add(quitItem);

    super.optionMenu = new JMenu("Options");

    final JMenu convertMenu = UIHelper.buildMenu("menu_convert");
    convertMenu.add(convertDCK);

    final JMenuItem helpItem = UIHelper.buildMenu("menu_help_help", 'h', this);
    helpItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F1, 0));

    final JMenu helpMenu = new JMenu("?");
    helpMenu.add(helpItem);
    helpMenu.add(deckConstraintsItem);
    helpMenu.add(aboutItem);

    final JMenuBar menuBar = new JMenuBar();
    menuBar.add(mainMenu);
    initAbstractMenu();
    menuBar.add(optionMenu);
    menuBar.add(convertMenu);
    menuBar.add(helpMenu);
    setJMenuBar(menuBar);
    addWindowListener(this);

    // Build the panel containing amount of available cards
    final JLabel amountLeft = new JLabel("<html>0/?", SwingConstants.RIGHT);

    // Build the left list
    allListModel = new MListModel<MCardCompare>(amountLeft, false);
    leftList = new ThreadSafeJList(allListModel);
    leftList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    leftList.setLayoutOrientation(JList.VERTICAL);
    leftList.getSelectionModel().addListSelectionListener(this);
    leftList.addMouseListener(this);
    leftList.setVisibleRowCount(10);

    // Initialize the text field containing the amount to add
    addQtyTxt = new JTextField("1");

    // Build the "Add" button
    addButton = new JButton(LanguageManager.getString("db_add"));
    addButton.setMnemonic('a');
    addButton.setEnabled(false);

    // Build the panel containing : "Add" amount and "Add" button
    final Box addPanel = Box.createHorizontalBox();
    addPanel.add(addButton);
    addPanel.add(addQtyTxt);
    addPanel.setMaximumSize(new Dimension(32010, 26));

    // Build the panel containing the selected card name
    cardNameTxt = new JTextField();
    new HireListener(cardNameTxt, addButton, this, leftList);

    final JLabel searchLabel = new JLabel(LanguageManager.getString("db_search") + " : ");
    searchLabel.setLabelFor(cardNameTxt);

    // Build the panel containing search label and card name text field
    final Box searchPanel = Box.createHorizontalBox();
    searchPanel.add(searchLabel);
    searchPanel.add(cardNameTxt);
    searchPanel.setMaximumSize(new Dimension(32010, 26));

    listScrollerLeft = new JScrollPane(leftList);
    MToolKit.addOverlay(listScrollerLeft);

    // Build the left panel containing : list, available amount, "Add" panel
    final JPanel srcPanel = new JPanel(null);
    srcPanel.add(searchPanel);
    srcPanel.add(listScrollerLeft);
    srcPanel.add(amountLeft);
    srcPanel.add(addPanel);
    srcPanel.setMinimumSize(new Dimension(220, 200));
    srcPanel.setLayout(new BoxLayout(srcPanel, BoxLayout.Y_AXIS));

    // Initialize constraints
    constraintsChecker = new ConstraintsChecker();
    constraintsChecker.setBorder(new EtchedBorder());
    final JScrollPane constraintsCheckerScroll = new JScrollPane(constraintsChecker);
    MToolKit.addOverlay(constraintsCheckerScroll);

    // create a pane with the oracle text for the present card
    oracleText = new JLabel();
    oracleText.setPreferredSize(new Dimension(180, 200));
    oracleText.setVerticalAlignment(SwingConstants.TOP);

    final JScrollPane oracle = new JScrollPane(oracleText, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED,
            ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
    MToolKit.addOverlay(oracle);

    // build some Pie Charts and a panel to display it
    initSets();
    datasets = new ChartSets();
    final JTabbedPane tabbedPane = new JTabbedPane();
    for (ChartFilter filter : ChartFilter.values()) {
        final Dataset dataSet = filter.createDataSet(this);
        final JFreeChart chart = new JFreeChart(null, null,
                filter.createPlot(dataSet, painterMapper.get(filter)), false);
        datasets.addDataSet(filter, dataSet);
        ChartPanel pieChartPanel = new ChartPanel(chart, true);
        tabbedPane.add(pieChartPanel, filter.getTitle());
    }
    // add the Constraints scroll panel and Oracle text Pane to the tabbedPane
    tabbedPane.add(constraintsCheckerScroll, LanguageManager.getString("db_constraints"));
    tabbedPane.add(oracle, LanguageManager.getString("db_text"));
    tabbedPane.setSelectedComponent(oracle);

    // The toollBar for color filtering
    toolBar = new JToolBar();
    toolBar.setFloatable(false);
    final JButton clearButton = UIHelper.buildButton("clear");
    clearButton.addActionListener(this);
    toolBar.add(clearButton);
    final JToggleButton toggleColorlessButton = new JToggleButton(
            UIHelper.getTbsIcon("mana/colorless/small/" + MdbLoader.unknownSmlMana), true);
    toggleColorlessButton.setActionCommand("0");
    toggleColorlessButton.addActionListener(this);
    toolBar.add(toggleColorlessButton);
    for (int index = 1; index < IdCardColors.CARD_COLOR_NAMES.length; index++) {
        final JToggleButton toggleButton = new JToggleButton(
                UIHelper.getTbsIcon("mana/colored/small/" + MdbLoader.coloredSmlManas[index]), true);
        toggleButton.setActionCommand(String.valueOf(index));
        toggleButton.addActionListener(this);
        toolBar.add(toggleButton);
    }

    // sorted card type combobox creation
    final List<String> idCards = new ArrayList<String>(Arrays.asList(CardFactory.exportedIdCardNames));
    Collections.sort(idCards);
    final Object[] cardTypes = ArrayUtils.addAll(new String[] { LanguageManager.getString("db_types.any") },
            idCards.toArray());
    idCardComboBox = new JComboBox(cardTypes);
    idCardComboBox.setSelectedIndex(0);
    idCardComboBox.addActionListener(this);
    idCardComboBox.setActionCommand("cardTypeFilter");

    // sorted card properties combobox creation
    final List<String> properties = new ArrayList<String>(
            CardFactory.getPropertiesName(DeckConstraints.getMinProperty(), DeckConstraints.getMaxProperty()));
    Collections.sort(properties);
    final Object[] cardProperties = ArrayUtils
            .addAll(new String[] { LanguageManager.getString("db_properties.any") }, properties.toArray());
    propertiesComboBox = new JComboBox(cardProperties);
    propertiesComboBox.setSelectedIndex(0);
    propertiesComboBox.addActionListener(this);
    propertiesComboBox.setActionCommand("propertyFilter");

    final JLabel colors = new JLabel(" " + LanguageManager.getString("colors") + " : ");
    final JLabel types = new JLabel(" " + LanguageManager.getString("types") + " : ");
    final JLabel property = new JLabel(" " + LanguageManager.getString("properties") + " : ");

    // filter Panel with colors toolBar and card type combobox
    final Box filterPanel = Box.createHorizontalBox();
    filterPanel.add(colors);
    filterPanel.add(toolBar);
    filterPanel.add(types);
    filterPanel.add(idCardComboBox);
    filterPanel.add(property);
    filterPanel.add(propertiesComboBox);

    getContentPane().add(filterPanel, BorderLayout.NORTH);

    // Destination section :

    // Build the panel containing amount of available cards
    final JLabel rightAmount = new JLabel("0/?", SwingConstants.RIGHT);
    rightAmount.setMaximumSize(new Dimension(220, 26));

    // Build the right list
    rightListModel = new MCardTableModel(new MListModel<MCardCompare>(rightAmount, true));
    rightListModel.addTableModelListener(this);
    rightList = new JTable(rightListModel);
    rightList.setShowGrid(false);
    rightList.setTableHeader(null);
    rightList.getSelectionModel().addListSelectionListener(this);
    rightList.getColumnModel().getColumn(0).setMaxWidth(25);
    rightList.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION);

    // Build the panel containing the selected deck
    deckNameTxt = new JTextField("loading...");
    deckNameTxt.setEditable(false);
    deckNameTxt.setBorder(null);
    final JLabel deckLabel = new JLabel(LanguageManager.getString("db_deck") + " : ");
    deckLabel.setLabelFor(deckNameTxt);
    final Box deckNamePanel = Box.createHorizontalBox();
    deckNamePanel.add(deckLabel);
    deckNamePanel.add(deckNameTxt);
    deckNamePanel.setMaximumSize(new Dimension(220, 26));

    // Initialize the text field containing the amount to remove
    removeQtyTxt = new JTextField("1");

    // Build the "Remove" button
    removeButton = new JButton(LanguageManager.getString("db_remove"));
    removeButton.setMnemonic('r');
    removeButton.addMouseListener(this);
    removeButton.setEnabled(false);

    // Build the panel containing : "Remove" amount and "Remove" button
    final Box removePanel = Box.createHorizontalBox();
    removePanel.add(removeButton);
    removePanel.add(removeQtyTxt);
    removePanel.setMaximumSize(new Dimension(220, 26));

    // Build the right panel containing : list, available amount, constraints
    final JScrollPane deskListScroller = new JScrollPane(rightList);
    MToolKit.addOverlay(deskListScroller);
    deskListScroller.setBorder(BorderFactory.createLineBorder(Color.GRAY));
    deskListScroller.setMinimumSize(new Dimension(220, 200));
    deskListScroller.setMaximumSize(new Dimension(220, 32000));

    final Box destPanel = Box.createVerticalBox();
    destPanel.add(deckNamePanel);
    destPanel.add(deskListScroller);
    destPanel.add(rightAmount);
    destPanel.add(removePanel);
    destPanel.setMinimumSize(new Dimension(220, 200));
    destPanel.setMaximumSize(new Dimension(220, 32000));

    // Build the panel containing the name of card in picture
    cardPictureNameTxt = new JLabel("<html><i>no selected card</i>");
    final Box cardPictureNamePanel = Box.createHorizontalBox();
    cardPictureNamePanel.add(cardPictureNameTxt);
    cardPictureNamePanel.setMaximumSize(new Dimension(32010, 26));

    // Group the detail panels
    final JPanel viewCard = new JPanel(null);
    viewCard.add(cardPictureNamePanel);
    viewCard.add(CardView.getInstance());
    viewCard.add(tabbedPane);
    viewCard.setLayout(new BoxLayout(viewCard, BoxLayout.Y_AXIS));

    final Box mainPanel = Box.createHorizontalBox();
    mainPanel.add(destPanel);
    mainPanel.add(viewCard);

    // Add the main panel
    getContentPane().add(srcPanel, BorderLayout.WEST);
    getContentPane().add(mainPanel, BorderLayout.CENTER);

    // Size this frame
    getRootPane().setPreferredSize(new Dimension(WINDOW_WIDTH, WINDOW_HEIGHT));
    getRootPane().setMinimumSize(getRootPane().getPreferredSize());
    pack();
}

From source file:ch.zhaw.simulation.diagram.charteditor.DefaultNumberAxisEditor.java

/**
 * Standard constructor: builds a property panel for the specified axis.
 * //w  w  w  .j  a  v  a2s  .co m
 * @param axis
 *            the axis, which should be changed.
 */
public DefaultNumberAxisEditor(NumberAxis axis) {
    super(axis);

    this.autoRange = axis.isAutoRange();
    this.minimumValue = axis.getLowerBound();
    this.maximumValue = axis.getUpperBound();

    this.gridPaintSample = new PaintSample(Color.blue);
    this.gridStrokeSample = new StrokeSample(new BasicStroke(1.0f));

    this.availableStrokeSamples = new StrokeSample[3];
    this.availableStrokeSamples[0] = new StrokeSample(new BasicStroke(1.0f));
    this.availableStrokeSamples[1] = new StrokeSample(new BasicStroke(2.0f));
    this.availableStrokeSamples[2] = new StrokeSample(new BasicStroke(3.0f));

    JTabbedPane other = getOtherTabs();

    JPanel range = new JPanel(new LCBLayout(3));
    range.setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4));

    range.add(new JPanel());
    this.autoRangeCheckBox = new JCheckBox(localizationResources.getString("Auto-adjust_range"),
            this.autoRange);
    this.autoRangeCheckBox.setActionCommand("AutoRangeOnOff");
    this.autoRangeCheckBox.addActionListener(this);
    range.add(this.autoRangeCheckBox);
    range.add(new JPanel());

    range.add(new JLabel(localizationResources.getString("Minimum_range_value")));
    this.minimumRangeValue = new JTextField(Double.toString(this.minimumValue));
    this.minimumRangeValue.setEnabled(!this.autoRange);
    this.minimumRangeValue.setActionCommand("MinimumRange");
    this.minimumRangeValue.addActionListener(this);
    this.minimumRangeValue.addFocusListener(this);
    range.add(this.minimumRangeValue);
    range.add(new JPanel());

    range.add(new JLabel(localizationResources.getString("Maximum_range_value")));
    this.maximumRangeValue = new JTextField(Double.toString(this.maximumValue));
    this.maximumRangeValue.setEnabled(!this.autoRange);
    this.maximumRangeValue.setActionCommand("MaximumRange");
    this.maximumRangeValue.addActionListener(this);
    this.maximumRangeValue.addFocusListener(this);
    range.add(this.maximumRangeValue);
    range.add(new JPanel());

    other.add(localizationResources.getString("Range"), range);

}

From source file:org.nuclos.client.layout.wysiwyg.component.properties.PropertyChartPropertyDomainStep.java

@Override
public void prepare() {
    super.prepare();

    chart = model.getChart();/*from   w w  w.  j ava2  s  .c  o  m*/
    wysiwygChart = model.getWYSIWYGChart();

    String sPrefix = getChartProperty(Chart.PROPERTY_COMBINED_PREFIXES);
    combinedPrefixes = (sPrefix == null) ? new StringBuffer("") : new StringBuffer(sPrefix);

    panel = new JPanel();
    panel.setLayout(new BorderLayout());

    final ChartFunction chartFunction = getChartFunction();

    if (!chartFunction.isCombinedChart()) {
        panel.add(getPanelComponent(chartFunction, ""), BorderLayout.CENTER);
    } else {
        JPanel editorType = new JPanel();
        editorType.setLayout(new GridBagLayout());
        JLabel propTypeValue = new JLabel(
                //SpringLocaleDelegate.getInstance().getMessage("wysiwyg.chart.wizard.domain.value",
                "Diagramm hinzufgen:"/*)*/);
        editorType.add(propTypeValue, new GridBagConstraints(0, 0, 0, 1, 1D, 1D, GridBagConstraints.NORTHWEST,
                GridBagConstraints.HORIZONTAL, new Insets(5, 0, 0, 0), 0, 0));
        final JComboBox propTypeComponent = new JComboBox(chartFunction.getCombinedChartFunctions());
        editorType.add(propTypeComponent, new GridBagConstraints(0, 1, 1, 1, 1D, 1D,
                GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, new Insets(5, 0, 15, 0), 0, 0));

        final JTabbedPane tabbedPane = new JTabbedPane();

        JButton removeButton = new JButton(iconRemove);
        removeButton.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                if (tabbedPane.getSelectedIndex() != -1) {
                    PanelComponent panelComponent = (PanelComponent) tabbedPane.getSelectedComponent();
                    combinedPrefixes = new StringBuffer(
                            combinedPrefixes.toString().replaceAll(panelComponent.prefix, ""));
                    tabbedPane.remove(panelComponent);
                }
            }
        });
        editorType.add(removeButton, new GridBagConstraints(1, 1, 1, 1, 1D, 1D, GridBagConstraints.NORTHEAST,
                GridBagConstraints.NONE, new Insets(5, 0, 0, 0), 0, 0));
        JButton addButton = new JButton(iconAdd);
        addButton.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                ChartFunction cFunction = (ChartFunction) propTypeComponent.getSelectedItem();
                String prefix = cFunction.name() + "." + (Math.random() + "").replaceAll("\\.", "") + ":";

                combinedPrefixes.append(prefix);
                tabbedPane.add(cFunction.name(), getPanelComponent(cFunction, prefix));
                tabbedPane.setSelectedIndex(tabbedPane.getTabCount() - 1);
            }
        });
        editorType.add(addButton, new GridBagConstraints(2, 1, 1, 1, 1D, 1D, GridBagConstraints.NORTHWEST,
                GridBagConstraints.NONE, new Insets(5, 0, 0, 0), 0, 0));

        String[] prefixes = combinedPrefixes.toString().split(":");
        for (String prefix : prefixes) {
            if (prefix.length() > 0) {
                try {
                    ChartFunction cFunction = ChartFunction.valueOf(prefix.split("\\.")[0]);
                    tabbedPane.add(cFunction.name(), getPanelComponent(cFunction, prefix + ":"));
                } catch (Exception e) {
                    // ignore.
                }
            }
        }
        panel.add(editorType, BorderLayout.NORTH);
        panel.add(tabbedPane, BorderLayout.CENTER);
    }
}

From source file:com.project.traceability.GUI.ProjectCreateWindow.java

/**
 * Create contents of the window.//from  w  ww  .  j a v  a2  s .  c  o m
 */
protected void createContents() {
    shell = new Shell();
    shell.setSize(622, 833);
    shell.setText("SWT Application");

    Dimension.toCenter(shell);// set the shell into center point
    Group group = new Group(shell, SWT.NONE);
    group.setText("Project");
    group.setBounds(20, 42, 556, 137);

    Label label = new Label(group, SWT.NONE);
    label.setText("New Workspace Path");
    label.setBounds(0, 5, 175, 18);

    lalProjectWrkspace = new Label(shell, SWT.NONE);
    lalProjectWrkspace.setText(StaticData.workspace);
    lalProjectWrkspace.setBounds(221, 10, 347, 17);

    textWrkspace = new Text(group, SWT.BORDER);
    textWrkspace.addKeyListener(new KeyAdapter() {
        @Override
        public void keyPressed(KeyEvent e) {

            if (e.keyCode == 10) {

                // The Project work space is entered and pressed enter
                // button
                String path = textWrkspace.getText().toString();
                File file = new File(path);

                if (!(file.isDirectory() || file.exists())) {
                    txtProjectName.setEnabled(true);
                    if (!(path.lastIndexOf(File.separator) == path.length() - 1)) {
                        path.concat(File.separator);
                    }
                    StaticData.workspace = path;
                } else {
                    MessageBox messageBox;
                    messageBox = new MessageBox(shell, SWT.ERROR);
                    messageBox.setMessage("Given Path is Invalid");
                    messageBox.setText("Invalid Path Exception");
                    messageBox.open();
                }
            }
        }
    });
    textWrkspace.setEnabled(false);
    textWrkspace.setEditable(false);
    textWrkspace.setBounds(181, 5, 290, 23);

    final Button buttonWrkspace = new Button(group, SWT.NONE);
    buttonWrkspace.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {

            DirectoryDialog dialog = new DirectoryDialog(shell);
            String str = dialog.open();

            if (!str.equals("")) {
                txtProjectName.setEnabled(true);
                textWrkspace.setText(str);
                lalProjectWrkspace.setText(str);
            }
        }
    });
    buttonWrkspace.setText("Browse");
    buttonWrkspace.setEnabled(false);
    buttonWrkspace.setBounds(477, 5, 75, 25);

    Label label_1 = new Label(group, SWT.NONE);
    label_1.setText("Traceabilty Project Name");
    label_1.setBounds(0, 75, 175, 21);

    Group group_1 = new Group(shell, SWT.NONE);
    group_1.setText("Import Required Files");
    group_1.setBounds(20, 190, 556, 174);

    Label label_3 = new Label(group_1, SWT.NONE);
    label_3.setText("Requirement File");
    label_3.setBounds(10, 37, 137, 18);

    txtRequirementPath = new Text(group_1, SWT.BORDER);
    txtRequirementPath.addKeyListener(new KeyAdapter() {
        @Override
        public void keyReleased(KeyEvent e) {

            if (!txtRequirementPath.getText().equals("")) {
                if (!txtUmlPath.getText().equals("") && !txtProjectPath.getText().equals("")
                        && !text_1.getText().equals("") && !text_2.getText().equals("")
                        && !text_3.getText().equals("") && !text_5.getText().equals("")
                        && !text_6.getText().equals("")) {
                    btnFinish.setEnabled(true);
                }
            } else {
                btnFinish.setEnabled(false);
            }
        }
    });
    txtRequirementPath.setEnabled(false);
    txtRequirementPath.setEditable(false);
    txtRequirementPath.setBounds(153, 31, 317, 27);

    btnReqBrwse = new Button(group_1, SWT.NONE);
    btnReqBrwse.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {

            org.eclipse.swt.widgets.FileDialog fileDialog = new org.eclipse.swt.widgets.FileDialog(shell,
                    SWT.SINGLE);
            fileDialog.setText("Open");
            fileDialog.setFilterExtensions(req_formats); // Windows
            fileDialog.setFilterPath(PropertyFile.docsFilePath);
            localFilePath = fileDialog.open();
            if (localFilePath != null) {
                PropertyFile.docsFilePath = localFilePath;
                txtRequirementPath.setText(PropertyFile.docsFilePath);
            }
        }
    });
    btnReqBrwse.setText("Browse");
    btnReqBrwse.setEnabled(false);
    btnReqBrwse.setBounds(476, 31, 75, 29);

    Label label_4 = new Label(group_1, SWT.NONE);
    label_4.setText("Design Diagram File");
    label_4.setBounds(10, 81, 137, 18);

    txtUmlPath = new Text(group_1, SWT.BORDER);
    txtUmlPath.addKeyListener(new KeyAdapter() {
        @Override
        public void keyReleased(KeyEvent e) {

            if (!txtUmlPath.getText().equals("")) {
                if (!txtRequirementPath.getText().equals("") && !txtProjectPath.getText().equals("")
                        && !text_1.getText().equals("") && !text_2.getText().equals("")
                        && !text_3.getText().equals("") && !text_5.getText().equals("")
                        && !text_6.getText().equals("")) {
                    btnFinish.setEnabled(true);
                }
            } else {
                btnFinish.setEnabled(false);
            }

        }
    });
    txtUmlPath.setEnabled(false);
    txtUmlPath.setEditable(false);
    txtUmlPath.setBounds(153, 72, 317, 27);

    final Button btnUmlBrwse = new Button(group_1, SWT.NONE);
    btnUmlBrwse.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {

            org.eclipse.swt.widgets.FileDialog fileDialog = new org.eclipse.swt.widgets.FileDialog(shell,
                    SWT.MULTI);
            fileDialog.setText("Open");
            fileDialog.setFilterExtensions(uml_formats); // Windows
            fileDialog.setFilterPath(StaticData.umlFilePath);
            localFilePath = fileDialog.open();
            StaticData.umlFilePath = localFilePath;
            localFilePath = localFilePath.replace(Paths.get(localFilePath).getFileName().toString(), "");
            if (localFilePath != null) {
                txtUmlPath.setText(StaticData.umlFilePath);
            }
        }
    });
    btnUmlBrwse.setText("Browse");
    btnUmlBrwse.setEnabled(false);
    btnUmlBrwse.setBounds(476, 74, 75, 27);

    Label label_5 = new Label(group_1, SWT.NONE);
    label_5.setText("Project Path");
    label_5.setBounds(10, 126, 137, 18);

    txtProjectPath = new Text(group_1, SWT.BORDER);
    txtProjectPath.addKeyListener(new KeyAdapter() {
        @Override
        public void keyReleased(KeyEvent e) {
            if (!txtProjectPath.getText().equals("")) {
                if (!txtRequirementPath.getText().equals("") && !txtUmlPath.getText().equals("")
                        && !text_1.getText().equals("") && !text_2.getText().equals("")
                        && !text_3.getText().equals("") && !text_5.getText().equals("")
                        && !text_6.getText().equals("")) {
                    btnFinish.setEnabled(true);
                }
            } else {
                btnFinish.setEnabled(false);
            }

        }
    });
    txtProjectPath.setEnabled(false);
    txtProjectPath.setEditable(false);
    txtProjectPath.setBounds(153, 120, 317, 27);

    final Button btnSrcBrwse = new Button(group_1, SWT.NONE);
    btnSrcBrwse.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {

            /*
             * Pop up File Chooser Window
             */
            DirectoryDialog directoryDialog = new DirectoryDialog(shell);
            directoryDialog.setText("Open");
            localFilePath = directoryDialog.open();
            StaticData.sourceFilePath = localFilePath;
            localFilePath = localFilePath.replace(Paths.get(localFilePath).getFileName().toString(), "");
            String root = "";// HomeGUI.tree.getToolTipText() +
                             // File.separator +
                             // txtProjectName.getText();
            String path = root + File.separator + FilePropertyName.SOURCE_CODE;
            srcJavaDir = new File(path);
            if (localFilePath != null) {
                txtProjectPath.setText(StaticData.sourceFilePath);
                boolean src = AccessProject.javaFilesExists(new File(StaticData.sourceFilePath.toString()));
                System.out.println("Java Files " + src);

                // &&!text_1.getText().equals("")&&!text_2.getText().equals("")&&!text_3.getText().equals("")&&!text_5.getText().equals("")&&!text_6.getText().equals("")
                if (src) {
                    if (!txtRequirementPath.getText().equals("") && !txtUmlPath.getText().equals("")) {

                        btnFinish.setEnabled(true);
                    }
                } else {
                    txtProjectPath.setText("");
                    // JOptionPane.showMessageDialog(null, "Error in java
                    // project file path...", "Java Project Error",
                    // JOptionPane.ERROR_MESSAGE);
                }
            }
        }
    });
    btnSrcBrwse.setText("Browse");
    btnSrcBrwse.setEnabled(false);
    btnSrcBrwse.setBounds(476, 120, 75, 27);

    final Button btnOk = new Button(group, SWT.NONE);
    btnOk.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            path_workspacepath = lalProjectWrkspace.getText();
            name_project = txtProjectName.getText();
            path_testfolder = path_workspacepath + File.separator + name_project;
            System.out.println(path_testfolder);
            try {
                FileUtils.forceMkdir(new File(path_testfolder));

            } catch (IOException e1) {
                // TODO Auto-generated catch block
                e1.printStackTrace();
            }

            String projectName = txtProjectName.getText();
            if (isNameValid(projectName)) {
                txtRequirementPath.setEnabled(true);
                txtUmlPath.setEnabled(true);
                txtProjectPath.setEnabled(true);
                text_1.setEnabled(true);
                text_2.setEnabled(true);
                text_3.setEnabled(true);
                text_5.setEnabled(true);
                text_6.setEnabled(true);

                btnReqBrwse.setEnabled(true);
                btnSrcBrwse.setEnabled(true);
                btnUmlBrwse.setEnabled(true);
                button.setEnabled(true);
                button_1.setEnabled(true);
                button_3.setEnabled(true);
                button_5.setEnabled(true);
                button_6.setEnabled(true);

            } else {
                /*
                 * name is not valid produce pop up message to user
                 * 
                 */
            }
        }
    });
    btnOk.setBounds(477, 67, 77, 29);
    btnOk.setText("Ok");
    Composite composite = new Composite(shell, SWT.NONE);
    composite.setBounds(20, 648, 556, 62);

    final Label lblNewLabel = new Label(composite, SWT.NONE);
    lblNewLabel.setBounds(24, 10, 459, 17);
    lblNewLabel.setText("");
    lblNewLabel.setForeground(new org.eclipse.swt.graphics.Color(Display.getCurrent(), 255, 0, 0));

    txtProjectName = new Text(group, SWT.BORDER);
    txtProjectName.addKeyListener(new KeyAdapter() {
        @Override
        public void keyPressed(KeyEvent e) {
            //
            // File file = new
            // File(StaticData.workspace,txtProjectName.getText());
            // if(file.exists()){
            // btnOk.setEnabled(false);
            // }else{
            // btnOk.setEnabled(true);
            // }
        }

        @Override
        public void keyReleased(KeyEvent e) {

            File file = new File(StaticData.workspace, txtProjectName.getText());
            String typedName = txtProjectName.getText();
            boolean isProjectNameExists = isProjectExists(typedName);
            lblNewLabel.setText("");
            if (file.exists() || isProjectNameExists) {
                btnOk.setEnabled(false);

                txtRequirementPath.setEnabled(false);
                txtUmlPath.setEnabled(false);
                txtProjectPath.setEnabled(false);

                btnReqBrwse.setEnabled(false);
                btnSrcBrwse.setEnabled(false);
                btnUmlBrwse.setEnabled(false);

                btnFinish.setEnabled(false);

                if (!typedName.equals(""))
                    lblNewLabel.setText(
                            "You typed project name exists in " + allProjectsNamePathMap.get(typedName));
                else
                    lblNewLabel.setText("Project Name should not empty");
            } else {
                btnOk.setEnabled(true);
                lblNewLabel.setForeground(new org.eclipse.swt.graphics.Color(Display.getCurrent(), 255, 0, 0));
                lblNewLabel.setText("Project Name is valid");
            }
        }

        private boolean isProjectExists(String text) {
            // TODO Auto-generated method stub
            boolean isExits = false;
            if (allProjectsNamePathMap != null && allProjectsNamePathMap.containsKey(text)) {
                isExits = false;
            } else {
                // no need
                List<String> names = new ArrayList<>(allProjectsNamePathMap.keySet());
                for (String name : names) {
                    if (name.equals(text)) {
                        isExits = true;
                        return isExits;
                    }
                }
                isExits = false;
            }

            return isExits;
        }
    });
    txtProjectName.setText("");
    txtProjectName.setEnabled(true);
    txtProjectName.setBounds(182, 72, 278, 24);

    final Button btnNewWrkspace = new Button(group, SWT.CHECK);
    btnNewWrkspace.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {

            if (!btnNewWrkspace.getSelection()) {
                buttonWrkspace.setEnabled(false);
                textWrkspace.setEnabled(false);
                txtProjectName.setEnabled(true);
                btnOk.setEnabled(true);
            } else {
                buttonWrkspace.setEnabled(true);
                textWrkspace.setEnabled(true);
                txtProjectName.setEnabled(false);
                btnOk.setEnabled(false);
            }
        }
    });
    btnNewWrkspace.setText("Create New Workspace");
    btnNewWrkspace.setBounds(270, 34, 199, 24);

    button_2 = new Button(composite, SWT.NONE);
    button_2.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            shell.dispose();
        }
    });

    lblNewLabel.setText("");
    lblNewLabel.setForeground(new org.eclipse.swt.graphics.Color(Display.getCurrent(), 255, 0, 0));

    button_2.setText("Cancel");
    // button_2.setImage(SWTResourceManager.getImage("null"));
    button_2.setBounds(10, 29, 75, 25);

    btnFinish = new Button(composite, SWT.NONE);
    btnFinish.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {

            // MainClass mainClass = new
            // MainClass(text_5.getText(),text_6.getText());
            // mainClass.startConfig();
            //
            // Main m = new Main(text_1.getText(),text_2.getText());
            // m.startDeployment();
            //
            //
            // try {
            // TestAST testAST = new TestAST(text_3.getText());
            // testAST.TestingTraceability();
            // } catch (IOException e1) {
            // // TODO Auto-generated catch block
            // e1.printStackTrace();
            // } catch (TransformerException e1) {
            // // TODO Auto-generated catch block
            // e1.printStackTrace();
            // }
            //

            String projectName = txtProjectName.getText();

            // making script file for this project
            File file_root_script_folder = new File(PropertyFile.configuration_root + "scripts");
            if (!file_root_script_folder.exists())// home/shiyam/SAT_CONFIGS/scripts/
                file_root_script_folder.mkdirs(); // making script file for
            // each projects

            File script_file = FilePropertyName.createScriptFile(projectName + ".py");

            String scripts = ScriptContents.getContents(projectName);
            FilePropertyName.writeScriptContent(script_file, scripts);
            // finished the script file creation

            String reqFilePath = PropertyFile.docsFilePath;
            String umFilePath = StaticData.umlFilePath;
            String srcFilePath = StaticData.sourceFilePath;

            if (!(StaticData.workspace.lastIndexOf(File.separator) == StaticData.workspace.length() - 1)) {
                StaticData.workspace += (File.separator);
            }

            File projectRoot = new File(StaticData.workspace + projectName + File.separator);
            try {
                projectRoot.mkdir();
                ProjectCreateWindow.projectName = projectName;
            } catch (Exception e1) {
                // TODO Auto-generated catch block
                e1.printStackTrace();
            }
            File reqFile = new File(reqFilePath);
            File umlFile = new File(umFilePath);
            File srcFile = new File(srcFilePath);

            String projectAbsoulutePath = projectRoot.getAbsolutePath();
            System.out.println("!234");
            if (!(projectAbsoulutePath.lastIndexOf(File.separator) == projectAbsoulutePath.length() - 1)) {
                projectAbsoulutePath += (File.separator);
            }

            File srcFolder = new File(projectAbsoulutePath + FilePropertyName.SOURCE_CODE);
            try {
                srcFolder.mkdir();
                FilePropertyName.copyFolder(srcFile, srcFolder);

                File txtFolder = new File(projectAbsoulutePath + FilePropertyName.REQUIREMENT);
                txtFolder.mkdir();

                FilePropertyName.copyFile(reqFile, txtFolder);

                File umlFolder = new File(projectAbsoulutePath + FilePropertyName.UML);
                umlFolder.mkdir();

                FilePropertyName.copyFile(umlFile, umlFolder);

                File xmlFolder = new File(projectAbsoulutePath + FilePropertyName.XML);
                xmlFolder.mkdir();
                // PropertyFile.setRelationshipXMLPath(xmlFolder +
                // File.separator + FilePropertyName.RELATION_NAME);

                RelationManager.createXML(projectAbsoulutePath.substring(0, projectAbsoulutePath.length() - 1));
                // RelationManager.createXML(projectAbsoulutePath+FilePropertyName.XML);

                File propertyFolder = new File(projectAbsoulutePath + FilePropertyName.PROPERTY);
                propertyFolder.mkdir();

                // projectPath = PropertyFile.filePath + File.separator;
                projectPath = PropertyFile.filePath;
                System.out.println("---Project create window : line473 : " + projectPath);
                PropertyFile.setProjectName(projectName);
                PropertyFile.setGraphDbPath(projectPath + File.separator + FilePropertyName.PROPERTY
                        + File.separator + projectName + ".graphdb");
                PropertyFile.setGeneratedGexfFilePath(projectPath + File.separator + FilePropertyName.PROPERTY
                        + File.separator + projectName + ".gexf");
                PropertyFile.setRelationshipXMLPath(projectPath + "Relations.xml");

                HomeGUI.shell.setText("SAT- " + projectName);
                HomeGUI.newTab.setVisible(true);
                HomeGUI.tree.setVisible(true);

                System.out.println("---Project create window : line486 : " + projectPath);
                RelationManager.createXML(projectPath + projectName);

                /*
                 * write the sat_configuration.xml file with new project
                 * node and workspace node if needed
                 */
                Adapter.wrkspace = StaticData.workspace;
                Adapter.projectPath = StaticData.workspace + projectName;
                Adapter.createProjectNode();

                String temp = lalProjectWrkspace.getText().concat(File.separator);

                if (!temp.equals(StaticData.workspace)) {
                    StaticData.workspace = temp;
                    Adapter.createwrkpace("false");
                } else {
                    StaticData.workspace = temp;
                    Adapter.changeExistingWrkspaceStatus(StaticData.workspace, false);
                }
                System.out.println("Name: " + reqFilePath);
                // String[] names=reqFilePath.split(""+File.separator);
                // String requirementFileName=names[names.length-1];
                String requirementFileName = reqFilePath.substring(reqFilePath.lastIndexOf(File.separator));
                System.out.println("Re: " + requirementFileName);
                StaticData.requirementFilePath = projectAbsoulutePath + FilePropertyName.REQUIREMENT
                        + File.separator + requirementFileName;
                System.out
                        .println("----------Requirement file path--------- " + StaticData.requirementFilePath);

                Thread requirementThread = new Thread(new Runnable() {
                    public void run() {
                        try {
                            XMLConversion.convertRequirementFile();
                        } catch (Exception ex) {
                            Exceptions.printStackTrace(ex);
                        }
                    }
                });
                requirementThread.start();

                Thread javaFilesThread = new Thread(new Runnable() {
                    @Override
                    public void run() {
                        try {
                            XMLConversion.convertJavaFiles();
                        } catch (Exception ex) {
                            Exceptions.printStackTrace(ex);
                        }
                    }
                });
                javaFilesThread.start();

                Thread umlThread = new Thread(new Runnable() {
                    @Override
                    public void run() {
                        XMLConversion.convertUMLFile();
                    }
                });
                umlThread.start();

                while (requirementThread.isAlive() || javaFilesThread.isAlive() || umlThread.isAlive()) {
                    StringBuilder aliveThread = new StringBuilder();
                    if (requirementThread.isAlive()) {
                        aliveThread.append("Requirement");
                        aliveThread.append(" ");
                    }
                    if (javaFilesThread.isAlive()) {
                        aliveThread.append("Source Code");
                        aliveThread.append(" ");
                    }
                    if (umlThread.isAlive()) {
                        aliveThread.append("UML");
                        aliveThread.append(" ");
                    }

                    lblNewLabel.setText(aliveThread.toString() + " Extraction On Progress");

                }
                System.out.println("Thread finished");
                /*
                 * XMLConversion.convertRequirementFile();
                 * XMLConversion.convertUMLFile();
                 * XMLConversion.convertJavaFiles();
                 */
                shell.dispose();
                HomeGUI.closeMain(HomeGUI.shell);
                HomeGUI.main(null);

            } catch (IOException e1) {
                displayError(e1.toString());
            } catch (Exception e12) {
                displayError(e12.toString());
                shell.dispose();
                HomeGUI.closeMain(HomeGUI.shell);
                HomeGUI.main(null);
            }
            // System.out.println("NLP OK...........");

        }

    });
    btnFinish.setText("Development");
    btnFinish.setEnabled(false);
    btnFinish.setBounds(471, 29, 75, 25);

    Button btnConfiguration = new Button(composite, SWT.NONE);
    btnConfiguration.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent arg0) {
            MainClass mainClass = new MainClass(text_5.getText(), text_6.getText());
            mainClass.startConfig();
            panels.put("config", config(configname));

            JTabbedPane pane = new JTabbedPane();
            pane.add("Config", panels.get("config"));

            if (panels.containsKey("test")) {
                pane.add("Test", panels.get("test"));
            }
            if (panels.containsKey("deploy")) {
                pane.add("Deploy", panels.get("deploy"));
            }
            frame1.remove(jTabbedPane);
            frame1.add(pane);
            jTabbedPane = pane;
            frame1.pack();
            frame1.setVisible(true);
        }
    });
    btnConfiguration.setText("Configuration");
    btnConfiguration.setEnabled(true);
    btnConfiguration.setBounds(120, 29, 94, 25);

    Button btnDeployment = new Button(composite, SWT.NONE);
    btnDeployment.setBounds(367, 29, 75, 25);
    btnDeployment.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent arg0) {
            try {
                Thread.sleep(3000);
            } catch (InterruptedException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
            Main m = new Main(text_1.getText(), text_2.getText());
            m.startDeployment();

            panels.put("deploy", deploy(deployname));

            JTabbedPane pane = new JTabbedPane();
            pane.add("Deploy", panels.get("deploy"));

            if (panels.containsKey("test")) {
                pane.add("Test", panels.get("test"));
            }
            if (panels.containsKey("config")) {
                pane.add("Config", panels.get("config"));
            }
            frame1.remove(jTabbedPane);
            frame1.add(pane);
            jTabbedPane = pane;
            frame1.pack();
            frame1.setVisible(true);
        }
    });
    btnDeployment.setText("Deployment");
    btnDeployment.setEnabled(true);

    Button btnTesting = new Button(composite, SWT.NONE);
    btnTesting.setBounds(251, 29, 75, 25);
    btnTesting.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent arg0) {
            try {
                TestAST testAST = new TestAST(text_3.getText());
                testAST.TestingTraceability(path_testfolder);

                panels.put("test", test(testname));
                JTabbedPane pane = new JTabbedPane();
                pane.add("Test", panels.get("test"));

                if (panels.containsKey("config")) {
                    pane.add("Config", panels.get("config"));
                }
                if (panels.containsKey("deploy")) {
                    pane.add("Deploy", panels.get("deploy"));
                }

                frame1.remove(jTabbedPane);
                frame1.add(pane);
                jTabbedPane = pane;
                frame1.pack();
                frame1.setVisible(true);

            } catch (IOException e1) {
                // TODO Auto-generated catch block
                e1.printStackTrace();
            } catch (TransformerException e1) {
                // TODO Auto-generated catch block
                e1.printStackTrace();
            }
        }
    });
    btnTesting.setText("Testing");
    btnTesting.setEnabled(true);

    Label label_6 = new Label(shell, SWT.NONE);
    label_6.setText("New project will be created ");
    label_6.setBounds(20, 10, 189, 17);

    Group grpExetendedSatAnalizer = new Group(shell, SWT.NONE);
    grpExetendedSatAnalizer.setText("Exetended SAT Analizer");
    grpExetendedSatAnalizer.setBounds(20, 370, 556, 272);

    Label lblDeploymentDiagramFile = new Label(grpExetendedSatAnalizer, SWT.NONE);
    lblDeploymentDiagramFile.setText("Deployment Diagram File");
    lblDeploymentDiagramFile.setBounds(10, 34, 137, 18);

    text_1 = new Text(grpExetendedSatAnalizer, SWT.BORDER);
    text_1.addKeyListener(new KeyAdapter() {
        @Override
        public void keyReleased(KeyEvent e) {

            if (!text_1.getText().equals("")) {
                if (!txtUmlPath.getText().equals("") && !txtProjectPath.getText().equals("")
                        && !txtRequirementPath.getText().equals("") && !text_2.getText().equals("")
                        && !text_3.getText().equals("") && !text_5.getText().equals("")
                        && !text_6.getText().equals("")) {
                    btnFinish.setEnabled(true);
                }
            } else {
                btnFinish.setEnabled(false);
            }
        }
    });
    text_1.setEnabled(false);
    text_1.setEditable(false);
    text_1.setBounds(153, 28, 317, 27);

    button = new Button(grpExetendedSatAnalizer, SWT.NONE);
    button.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {

            org.eclipse.swt.widgets.FileDialog fileDialog = new org.eclipse.swt.widgets.FileDialog(shell,
                    SWT.SINGLE);
            fileDialog.setText("Open");
            fileDialog.setFilterExtensions(all_formats); // Windows
            fileDialog.setFilterPath(PropertyFile.docsFilePath);
            localFilePath = fileDialog.open();
            if (localFilePath != null) {
                // PropertyFile.docsFilePath = localFilePath;
                text_1.setText(localFilePath);
            }
        }
    });
    button.setText("Browse");
    button.setEnabled(false);
    button.setBounds(476, 30, 75, 27);

    Label lblDockerFile = new Label(grpExetendedSatAnalizer, SWT.NONE);
    lblDockerFile.setText("Docker File");
    lblDockerFile.setBounds(10, 79, 137, 18);

    text_2 = new Text(grpExetendedSatAnalizer, SWT.BORDER);
    text_2.addKeyListener(new KeyAdapter() {
        @Override
        public void keyReleased(KeyEvent e) {

            if (!text_2.getText().equals("")) {
                if (!txtUmlPath.getText().equals("") && !txtProjectPath.getText().equals("")
                        && !txtRequirementPath.getText().equals("") && !text_1.getText().equals("")
                        && !text_3.getText().equals("") && !text_5.getText().equals("")
                        && !text_6.getText().equals("")) {
                    btnFinish.setEnabled(true);
                }
            } else {
                btnFinish.setEnabled(false);
            }
        }
    });
    text_2.setEnabled(false);
    text_2.setEditable(false);
    text_2.setBounds(153, 73, 317, 27);

    button_1 = new Button(grpExetendedSatAnalizer, SWT.NONE);
    button_1.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {

            org.eclipse.swt.widgets.FileDialog fileDialog = new org.eclipse.swt.widgets.FileDialog(shell,
                    SWT.SINGLE);
            fileDialog.setText("Open");
            fileDialog.setFilterExtensions(all_formats); // Windows
            fileDialog.setFilterPath(PropertyFile.docsFilePath);
            localFilePath = fileDialog.open();
            if (localFilePath != null) {
                // PropertyFile.docsFilePath = localFilePath;
                text_2.setText(localFilePath);
            }
        }
    });
    button_1.setText("Browse");
    button_1.setEnabled(false);
    button_1.setBounds(476, 75, 75, 27);

    Label lblTestCases = new Label(grpExetendedSatAnalizer, SWT.NONE);
    lblTestCases.setText("Test case Path");
    lblTestCases.setBounds(10, 124, 137, 18);

    text_3 = new Text(grpExetendedSatAnalizer, SWT.BORDER);
    text_3.addKeyListener(new KeyAdapter() {
        @Override
        public void keyReleased(KeyEvent e) {

            if (!text_3.getText().equals("")) {
                if (!txtUmlPath.getText().equals("") && !txtProjectPath.getText().equals("")
                        && !txtRequirementPath.getText().equals("") && !text_1.getText().equals("")
                        && !text_2.getText().equals("") && !text_5.getText().equals("")
                        && !text_6.getText().equals("")) {
                    btnFinish.setEnabled(true);
                }
            } else {
                btnFinish.setEnabled(false);
            }
        }
    });
    text_3.setEnabled(false);
    text_3.setEditable(false);
    text_3.setBounds(153, 118, 317, 27);

    button_3 = new Button(grpExetendedSatAnalizer, SWT.NONE);
    button_3.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {

            /*
             * Pop up File Chooser Window
             */
            DirectoryDialog directoryDialog = new DirectoryDialog(shell);
            directoryDialog.setText("Open");
            localFilePath = directoryDialog.open();
            StaticData.sourceFilePath = localFilePath;
            localFilePath = localFilePath.replace(Paths.get(localFilePath).getFileName().toString(), "");
            String root = "";// HomeGUI.tree.getToolTipText() +
                             // File.separator +
                             // txtProjectName.getText();
            String path = root + File.separator + FilePropertyName.SOURCE_CODE;
            srcJavaDir = new File(path);
            if (localFilePath != null) {
                text_3.setText(localFilePath);
                boolean src = AccessProject.javaFilesExists(new File(StaticData.sourceFilePath.toString()));
                System.out.println("Test Java Files " + src);

            }
        }
    });
    button_3.setText("Browse");
    button_3.setEnabled(false);
    button_3.setBounds(476, 120, 75, 27);

    Label lblPropertyFile = new Label(grpExetendedSatAnalizer, SWT.NONE);
    lblPropertyFile.setText("Property File");
    lblPropertyFile.setBounds(10, 173, 137, 18);

    text_5 = new Text(grpExetendedSatAnalizer, SWT.BORDER);
    text_5.addKeyListener(new KeyAdapter() {
        @Override
        public void keyReleased(KeyEvent e) {

            if (!text_5.getText().equals("")) {
                if (!txtUmlPath.getText().equals("") && !txtProjectPath.getText().equals("")
                        && !txtRequirementPath.getText().equals("") && !text_1.getText().equals("")
                        && !text_2.getText().equals("") && !text_3.getText().equals("")
                        && !text_6.getText().equals("")) {
                    btnFinish.setEnabled(true);
                }
            } else {
                btnFinish.setEnabled(false);
            }
        }
    });
    text_5.setEnabled(false);
    text_5.setEditable(false);
    text_5.setBounds(153, 167, 317, 27);
    button_5 = new Button(grpExetendedSatAnalizer, SWT.NONE);

    button_5.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {

            org.eclipse.swt.widgets.FileDialog fileDialog = new org.eclipse.swt.widgets.FileDialog(shell,
                    SWT.SINGLE);
            fileDialog.setText("Open");
            fileDialog.setFilterExtensions(config_formats); // Windows
            fileDialog.setFilterPath(PropertyFile.docsFilePath);
            localFilePath = fileDialog.open();
            if (localFilePath != null) {
                // PropertyFile.docsFilePath = localFilePath;
                text_5.setText(localFilePath);
            }
        }
    });
    button_5.setText("Browse");
    button_5.setEnabled(false);
    button_5.setBounds(476, 169, 75, 27);

    Label lblConfigurationFile = new Label(grpExetendedSatAnalizer, SWT.NONE);
    lblConfigurationFile.setText("Configuration Text File");
    lblConfigurationFile.setBounds(10, 208, 137, 18);

    text_6 = new Text(grpExetendedSatAnalizer, SWT.BORDER);
    text_6.addKeyListener(new KeyAdapter() {
        @Override
        public void keyReleased(KeyEvent e) {

            if (!text_6.getText().equals("")) {
                if (!txtUmlPath.getText().equals("") && !txtProjectPath.getText().equals("")
                        && !txtRequirementPath.getText().equals("") && !text_1.getText().equals("")
                        && !text_2.getText().equals("") && !text_3.getText().equals("")
                        && !text_5.getText().equals("")) {
                    btnFinish.setEnabled(true);
                }
            } else {
                btnFinish.setEnabled(false);
            }
        }
    });
    text_6.setEnabled(false);
    text_6.setEditable(false);
    text_6.setBounds(153, 202, 317, 27);

    button_6 = new Button(grpExetendedSatAnalizer, SWT.NONE);
    button_6.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {

            org.eclipse.swt.widgets.FileDialog fileDialog = new org.eclipse.swt.widgets.FileDialog(shell,
                    SWT.SINGLE);
            fileDialog.setText("Open");
            fileDialog.setFilterExtensions(req_formats); // Windows
            fileDialog.setFilterPath(PropertyFile.docsFilePath);
            localFilePath = fileDialog.open();
            if (localFilePath != null) {
                // PropertyFile.docsFilePath = localFilePath;
                text_6.setText(localFilePath);
            }
        }
    });
    button_6.setText("Browse");
    button_6.setEnabled(false);
    button_6.setBounds(476, 204, 75, 27);

}

From source file:edu.ku.brc.specify.utilapps.RegisterApp.java

/**
 * /* ww w.ja  v a2s .  com*/
 */
protected void createUI() {
    JTabbedPane tabbedPane = new JTabbedPane();

    rp = new RegProcessor();
    rp.processSQL();

    tree = new JTree(rp.getRoot(INCL_ANON));
    propsTable = new JTable();

    tree.getSelectionModel().addTreeSelectionListener(new TreeSelectionListener() {
        @Override
        public void valueChanged(TreeSelectionEvent e) {
            fillPropsTable();
        }
    });
    tree.setCellRenderer(new MyTreeCellRenderer());

    Component topComp = UIHelper.createScrollPane(tree);
    Component botComp = UIHelper.createScrollPane(propsTable);
    JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, topComp, botComp);

    splitPane.setDividerLocation(0.5);
    splitPane.setOneTouchExpandable(true);

    splitPane.setLastDividerLocation(300);
    Dimension minimumSize = new Dimension(200, 400);
    topComp.setMinimumSize(minimumSize);
    botComp.setMinimumSize(minimumSize);

    tabbedPane.add("Registration", splitPane);

    final List<Pair<String, String>> trackDescPairs = rp.getTrackKeyDescPairs();
    Vector<String> trkItems = new Vector<String>();
    for (Pair<String, String> p : trackDescPairs) {
        trkItems.add(p.second);
    }

    //Collections.sort(trkItems);
    final JList list = new JList(trkItems);
    //pb.add(UIHelper.createScrollPane(list), cc.xy(1, 1));
    list.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
        @Override
        public void valueChanged(ListSelectionEvent e) {
            if (!e.getValueIsAdjusting()) {
                int inx = list.getSelectedIndex();
                if (inx > -1) {
                    fillUsageItemsList(trackDescPairs.get(inx).first);
                }
            }
        }
    });

    tabbedPane.add("Reg Stats", getStatsPane("Registration", rp.getRegNumHash().values(), "register"));

    DefaultListModel model = new DefaultListModel();
    trackItemsList = new JList(model);

    topComp = UIHelper.createScrollPane(list);
    botComp = UIHelper.createScrollPane(trackItemsList);
    splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, topComp, botComp);
    splitPane.setDividerLocation(0.5);
    splitPane.setOneTouchExpandable(true);

    topComp.setMinimumSize(minimumSize);
    botComp.setMinimumSize(minimumSize);

    splitPane.setDividerLocation(0.5);
    trackUsageHash = rp.getTrackCatsHash();
    tabbedPane.add("Usage Tracking", splitPane);

    tabbedPane.add("User Stats", getStatsPane("Tracking", rp.getTrackIdHash().values(), "track"));

    add(tabbedPane, BorderLayout.CENTER);
}

From source file:davmail.ui.SettingsFrame.java

/**
 * DavMail settings frame.//from  w  w  w  .j  av  a2 s  .co m
 */
public SettingsFrame() {
    setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
    setTitle(BundleMessage.format("UI_DAVMAIL_SETTINGS"));
    try {
        setIconImage(DavGatewayTray.getFrameIcon());
    } catch (NoSuchMethodError error) {
        DavGatewayTray.debug(new BundleMessage("LOG_UNABLE_TO_SET_ICON_IMAGE"));
    }

    JTabbedPane tabbedPane = new JTabbedPane();
    // add help (F1 handler)
    tabbedPane.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put(KeyStroke.getKeyStroke("F1"),
            "help");
    tabbedPane.getActionMap().put("help", new AbstractAction() {
        public void actionPerformed(ActionEvent e) {
            DesktopBrowser.browse("http://davmail.sourceforge.net");
        }
    });
    tabbedPane.addChangeListener(new ChangeListener() {
        public void stateChanged(ChangeEvent e) {
            boolean isSslEnabled = isSslEnabled();
            popNoSSLCheckBox.setEnabled(Settings.getProperty("davmail.popPort") != null && isSslEnabled);
            imapNoSSLCheckBox.setEnabled(imapPortCheckBox.isSelected() && isSslEnabled);
            smtpNoSSLCheckBox.setEnabled(smtpPortCheckBox.isSelected() && isSslEnabled);
            caldavNoSSLCheckBox.setEnabled(caldavPortCheckBox.isSelected() && isSslEnabled);
            ldapNoSSLCheckBox.setEnabled(ldapPortCheckBox.isSelected() && isSslEnabled);
        }
    });

    JPanel mainPanel = new JPanel();
    mainPanel.setLayout(new BoxLayout(mainPanel, BoxLayout.Y_AXIS));
    mainPanel.add(getSettingsPanel());
    mainPanel.add(getDelaysPanel());
    mainPanel.add(Box.createVerticalGlue());

    tabbedPane.add(BundleMessage.format("UI_TAB_MAIN"), mainPanel);

    JPanel proxyPanel = new JPanel();
    proxyPanel.setLayout(new BoxLayout(proxyPanel, BoxLayout.Y_AXIS));
    proxyPanel.add(getProxyPanel());
    proxyPanel.add(getNetworkSettingsPanel());
    tabbedPane.add(BundleMessage.format("UI_TAB_NETWORK"), proxyPanel);

    JPanel encryptionPanel = new JPanel();
    encryptionPanel.setLayout(new BoxLayout(encryptionPanel, BoxLayout.Y_AXIS));
    encryptionPanel.add(getKeystorePanel());
    encryptionPanel.add(getSmartCardPanel());
    // empty panel
    encryptionPanel.add(new JPanel());
    tabbedPane.add(BundleMessage.format("UI_TAB_ENCRYPTION"), encryptionPanel);

    JPanel loggingPanel = new JPanel();
    loggingPanel.setLayout(new BoxLayout(loggingPanel, BoxLayout.Y_AXIS));
    loggingPanel.add(getLoggingSettingsPanel());
    // empty panel
    loggingPanel.add(new JPanel());

    tabbedPane.add(BundleMessage.format("UI_TAB_LOGGING"), loggingPanel);

    JPanel advancedPanel = new JPanel();
    advancedPanel.setLayout(new BoxLayout(advancedPanel, BoxLayout.Y_AXIS));

    advancedPanel.add(getOtherSettingsPanel());
    // empty panel
    advancedPanel.add(new JPanel());

    tabbedPane.add(BundleMessage.format("UI_TAB_ADVANCED"), advancedPanel);

    if (OSXInfoPlist.isOSX()) {
        JPanel osxPanel = new JPanel();
        osxPanel.setLayout(new BoxLayout(osxPanel, BoxLayout.Y_AXIS));
        osxPanel.add(getOSXPanel());
        // empty panel
        osxPanel.add(new JPanel());

        tabbedPane.add(BundleMessage.format("UI_TAB_OSX"), osxPanel);
    }

    add(BorderLayout.CENTER, tabbedPane);

    JPanel buttonPanel = new JPanel();
    JButton cancel = new JButton(BundleMessage.format("UI_BUTTON_CANCEL"));
    JButton ok = new JButton(BundleMessage.format("UI_BUTTON_SAVE"));
    JButton help = new JButton(BundleMessage.format("UI_BUTTON_HELP"));
    ActionListener save = new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            // save options
            Settings.setProperty("davmail.url", urlField.getText());
            Settings.setProperty("davmail.popPort", popPortCheckBox.isSelected() ? popPortField.getText() : "");
            Settings.setProperty("davmail.ssl.nosecurepop", String.valueOf(popNoSSLCheckBox.isSelected()));
            Settings.setProperty("davmail.imapPort",
                    imapPortCheckBox.isSelected() ? imapPortField.getText() : "");
            Settings.setProperty("davmail.ssl.nosecureimap", String.valueOf(imapNoSSLCheckBox.isSelected()));
            Settings.setProperty("davmail.smtpPort",
                    smtpPortCheckBox.isSelected() ? smtpPortField.getText() : "");
            Settings.setProperty("davmail.ssl.nosecuresmtp", String.valueOf(smtpNoSSLCheckBox.isSelected()));
            Settings.setProperty("davmail.caldavPort",
                    caldavPortCheckBox.isSelected() ? caldavPortField.getText() : "");
            Settings.setProperty("davmail.ssl.nosecurecaldav",
                    String.valueOf(caldavNoSSLCheckBox.isSelected()));
            Settings.setProperty("davmail.ldapPort",
                    ldapPortCheckBox.isSelected() ? ldapPortField.getText() : "");
            Settings.setProperty("davmail.ssl.nosecureldap", String.valueOf(ldapNoSSLCheckBox.isSelected()));
            Settings.setProperty("davmail.keepDelay", keepDelayField.getText());
            Settings.setProperty("davmail.sentKeepDelay", sentKeepDelayField.getText());
            Settings.setProperty("davmail.caldavPastDelay", caldavPastDelayField.getText());
            Settings.setProperty("davmail.imapIdleDelay", imapIdleDelayField.getText());
            Settings.setProperty("davmail.useSystemProxies",
                    String.valueOf(useSystemProxiesField.isSelected()));
            Settings.setProperty("davmail.enableProxy", String.valueOf(enableProxyField.isSelected()));
            Settings.setProperty("davmail.proxyHost", httpProxyField.getText());
            Settings.setProperty("davmail.proxyPort", httpProxyPortField.getText());
            Settings.setProperty("davmail.proxyUser", httpProxyUserField.getText());
            Settings.setProperty("davmail.proxyPassword", httpProxyPasswordField.getText());
            Settings.setProperty("davmail.noProxyFor", noProxyForField.getText());

            Settings.setProperty("davmail.bindAddress", bindAddressField.getText());
            Settings.setProperty("davmail.clientSoTimeout", String.valueOf(clientSoTimeoutField.getText()));
            Settings.setProperty("davmail.allowRemote", String.valueOf(allowRemoteField.isSelected()));
            Settings.setProperty("davmail.server.certificate.hash", certHashField.getText());
            Settings.setProperty("davmail.disableUpdateCheck", String.valueOf(disableUpdateCheck.isSelected()));

            Settings.setProperty("davmail.caldavEditNotifications",
                    String.valueOf(caldavEditNotificationsField.isSelected()));
            Settings.setProperty("davmail.caldavAlarmSound", String.valueOf(caldavAlarmSoundField.getText()));
            Settings.setProperty("davmail.forceActiveSyncUpdate",
                    String.valueOf(forceActiveSyncUpdateCheckBox.isSelected()));
            Settings.setProperty("davmail.defaultDomain", String.valueOf(defaultDomainField.getText()));
            Settings.setProperty("davmail.showStartupBanner",
                    String.valueOf(showStartupBannerCheckBox.isSelected()));
            Settings.setProperty("davmail.disableGuiNotifications",
                    String.valueOf(disableGuiNotificationsCheckBox.isSelected()));
            Settings.setProperty("davmail.imapAutoExpunge",
                    String.valueOf(imapAutoExpungeCheckBox.isSelected()));
            Settings.setProperty("davmail.popMarkReadOnRetr",
                    String.valueOf(popMarkReadOnRetrCheckBox.isSelected()));
            String selectedEwsMode = (String) enableEwsComboBox.getSelectedItem();
            String enableEws;
            if (EWS.equals(selectedEwsMode)) {
                enableEws = "true";
            } else if (WEBDAV.equals(selectedEwsMode)) {
                enableEws = "false";
            } else {
                enableEws = "auto";
            }
            Settings.setProperty("davmail.enableEws", enableEws);
            Settings.setProperty("davmail.smtpSaveInSent", String.valueOf(smtpSaveInSentCheckBox.isSelected()));

            Settings.setProperty("davmail.ssl.keystoreType", (String) keystoreTypeCombo.getSelectedItem());
            Settings.setProperty("davmail.ssl.keystoreFile", keystoreFileField.getText());
            Settings.setProperty("davmail.ssl.keystorePass", String.valueOf(keystorePassField.getPassword()));
            Settings.setProperty("davmail.ssl.keyPass", String.valueOf(keyPassField.getPassword()));

            Settings.setProperty("davmail.ssl.clientKeystoreType",
                    (String) clientKeystoreTypeCombo.getSelectedItem());
            Settings.setProperty("davmail.ssl.clientKeystoreFile", clientKeystoreFileField.getText());
            Settings.setProperty("davmail.ssl.clientKeystorePass",
                    String.valueOf(clientKeystorePassField.getPassword()));
            Settings.setProperty("davmail.ssl.pkcs11Library", pkcs11LibraryField.getText());
            Settings.setProperty("davmail.ssl.pkcs11Config", pkcs11ConfigField.getText());

            Settings.setLoggingLevel("rootLogger", (Level) rootLoggingLevelField.getSelectedItem());
            Settings.setLoggingLevel("davmail", (Level) davmailLoggingLevelField.getSelectedItem());
            Settings.setLoggingLevel("org.apache.commons.httpclient",
                    (Level) httpclientLoggingLevelField.getSelectedItem());
            Settings.setLoggingLevel("httpclient.wire", (Level) wireLoggingLevelField.getSelectedItem());
            Settings.setProperty("davmail.logFilePath", logFilePathField.getText());
            Settings.setProperty("davmail.logFileSize", logFileSizeField.getText());

            setVisible(false);
            Settings.save();

            if (osxHideFromDockCheckBox != null) {
                OSXInfoPlist.setOSXHideFromDock(osxHideFromDockCheckBox.isSelected());
            }

            // restart listeners with new config
            DavGateway.restart();
        }
    };
    ok.addActionListener(save);

    cancel.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            reload();
            setVisible(false);
        }
    });

    help.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            DesktopBrowser.browse("http://davmail.sourceforge.net");
        }
    });

    buttonPanel.add(ok);
    buttonPanel.add(cancel);
    buttonPanel.add(help);

    add(BorderLayout.SOUTH, buttonPanel);

    pack();
    //setResizable(false);
    // center frame
    setLocation(getToolkit().getScreenSize().width / 2 - getSize().width / 2,
            getToolkit().getScreenSize().height / 2 - getSize().height / 2);
    urlField.requestFocus();
}

From source file:fur.shadowdrake.minecraft.InstallPanel.java

public void begin(boolean first) {
    workingDir = dirBox.getText();/*from  ww  w .j a  v a 2 s .  com*/
    workingPack = (String) modpackChooser.getSelectedItem();
    parentFrame.dropAllProceedListeners();
    new Thread(() -> {
        try {
            JTabbedPane tabPane;
            tabPane = (JTabbedPane) getParent();

            if (force.isSelected()) {
                log.println("Cleaning up.");
                cleanUp(new File(workingDir));
                Manifest mf = manifest.get(workingPack);
                if (mf != null) {
                    mf.clear();
                }
            }

            Pack detected = detectPack(new File(workingDir));
            if ((detected == null) && checkDir(new File(workingDir), 2)) {
                try {
                    EventQueue.invokeAndWait(() -> {
                        JOptionPane.showMessageDialog(parentFrame,
                                "This directory contains an unknown modpack.\nChoose another directory or force reinstall.");
                    });
                } catch (InterruptedException | InvocationTargetException ex) {
                }
                completedListener.actionPerformed(new ActionEvent(this, 2, "Install"));
            } else if (detected == null) {
                try {
                    EventQueue.invokeAndWait(() -> {
                        tabPane.remove(this);
                    });
                } catch (InterruptedException | InvocationTargetException ex) {
                }

                if (first && !addonsOpenedOnce) {
                    addonsPanel = new AddonsPanel(
                            availablePacks.get(modpackChooser.getSelectedIndex()).addons.toArray(new Addon[0]));
                    tabPane.add("Addons", addonsPanel);
                    tabPane.setSelectedComponent(addonsPanel);
                    addonsOpenedOnce = true;
                    parentFrame.setAbortListener((ActionEvent e) -> {
                        tabPane.remove(addonsPanel);
                        tabPane.add("Install", this);
                        tabPane.setSelectedComponent(this);
                        parentFrame.setProceedListener((ActionEvent ev) -> {
                            begin(false);
                        });
                        parentFrame.setAbortListener((ActionEvent ev) -> {
                            tabPane.remove(this);
                            parentFrame.state = 0;
                            parentFrame.dropAllAbortListeners();
                            parentFrame.dropAllProceedListeners();
                        });
                    });
                    parentFrame.setProceedListener((ActionEvent e) -> {
                        tabPane.remove(addonsPanel);
                        boolean s[];
                        s = addonsPanel.getSelected();
                        for (int n = 0; n < s.length; n++) {
                            availablePacks.get(modpackChooser.getSelectedIndex()).addons.get(n).install = s[n];
                        }
                        begin(false);
                    });
                    return;
                }

                if (downloadPack() && downloadAddons() && doPostDownload()) {
                    log.println("Installation completed successful.");
                    log.setStatusText("Ok");
                    completedListener.actionPerformed(new ActionEvent(this, 1, "Install"));
                } else {
                    log.println("Installation completed with errors.");
                    log.setStatusText("Error");
                    EventQueue.invokeLater(() -> {
                        JOptionPane.showMessageDialog(parentFrame, "Installation failed");
                    });
                    completedListener.actionPerformed(new ActionEvent(this, 0, "Install"));
                }
            } else if (detected.name.equals(modpackChooser.getSelectedItem())) {
                if (!isInstalled(detected)) {
                    try {
                        Gson gson = new GsonBuilder().create();
                        tabPane.remove(this);
                        packList.add(detected);

                        String latestVersion = ftpClient.getLatestVersion(detected.name);
                        if (!latestVersion.equals(detected.version)) {
                            updatePack(detected);
                        }

                        try (FileWriter fw = new FileWriter(
                                new File(config.getInstallDir(), "modpacks.json"))) {
                            gson.toJson(packList, fw);
                        }
                        log.println("Installation completed successful.");
                        completedListener.actionPerformed(new ActionEvent(this, 1, "Install"));
                    } catch (IOException ex1) {
                        log.println("Installation failed.");
                        Logger.getLogger(InstallPanel.class.getName()).log(Level.SEVERE, null, ex1);
                    }
                } else {
                    try {
                        EventQueue.invokeAndWait(() -> {
                            tabPane.remove(this);
                        });
                    } catch (InterruptedException | InvocationTargetException ex) {
                    }
                    if (downloadAddons()) {
                        log.println("Installation completed successful.");
                        log.setStatusText("Ok");
                        log.reset();
                        completedListener.actionPerformed(new ActionEvent(this, 1, "Install"));
                    } else {
                        log.println("Installation failed.");
                        EventQueue.invokeLater(() -> {
                            JOptionPane.showMessageDialog(parentFrame, "Installation failed");
                        });
                    }
                }
            } else {
                try {
                    EventQueue.invokeAndWait(() -> {
                        JOptionPane.showMessageDialog(parentFrame, "This directory contains modpack "
                                + detected.name + ".\nSelect the correct pack or force reinstall.");
                    });
                } catch (InterruptedException | InvocationTargetException ex) {
                }
                completedListener.actionPerformed(new ActionEvent(this, 2, "Install"));
            }
            writeFiles();
        } catch (NetworkException ex) {
            Logger.getLogger(InstallPanel.class.getName()).log(Level.SEVERE, null, ex);
            JOptionPane.showMessageDialog(parentFrame, ex.getMessage(), "Network error",
                    JOptionPane.ERROR_MESSAGE);
            ftpClient.close();
            log.println(
                    "Timeout. Previous command wasn't received by the server. This is a network error. Please try again later.");
            log.setStatusText("Error");
        }
    }, "Installer").start();
}

From source file:org.apache.jmeter.protocol.http.config.gui.HttpDefaultsGui.java

private void init() { // WARNING: called from ctor so must not be overridden (i.e. must be private or final)
    setLayout(new BorderLayout(0, 5));
    setBorder(makeBorder());//from  w  w w. ja  v a  2 s .c om

    // URL CONFIG
    urlConfigGui = new UrlConfigGui(false, true, false);

    // AdvancedPanel (embedded resources, source address and optional tasks)
    JPanel advancedPanel = new VerticalPanel();
    advancedPanel.add(createEmbeddedRsrcPanel());
    advancedPanel.add(createSourceAddrPanel());
    advancedPanel.add(createOptionalTasksPanel());

    JTabbedPane tabbedPane = new JTabbedPane();
    tabbedPane.add(JMeterUtils.getResString("web_testing_basic"), urlConfigGui);
    tabbedPane.add(JMeterUtils.getResString("web_testing_advanced"), advancedPanel);

    JPanel emptyPanel = new JPanel();
    emptyPanel.setMaximumSize(new Dimension());

    add(makeTitlePanel(), BorderLayout.NORTH);
    add(tabbedPane, BorderLayout.CENTER);
    add(emptyPanel, BorderLayout.SOUTH);
}