Java Code Examples for javax.swing.JTabbedPane#addChangeListener()

The following examples show how to use javax.swing.JTabbedPane#addChangeListener() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: GUIPacket.java    From PacketProxy with Apache License 2.0 6 votes vote down vote up
public JComponent createPanel() throws Exception {
	received_panel = new GUIData(this.owner);
	decoded_panel = new GUIData(this.owner);
	modified_panel = new GUIData(this.owner);
	sent_panel = new GUIData(this.owner);
	all_panel = new GUIDataAll();

	packet_pane = new JTabbedPane();
	packet_pane.addTab("Received Packet", received_panel.createPanel());
	packet_pane.addTab("Decoded", decoded_panel.createPanel());
	packet_pane.addTab("Modified", modified_panel.createPanel());
	packet_pane.addTab("Encoded (Sent Packet)", sent_panel.createPanel());
	packet_pane.addTab("All", all_panel.createPanel());
	packet_pane.addChangeListener(new ChangeListener() {
		@Override
		public void stateChanged(ChangeEvent e) {
			try {
				update();
			} catch (Exception e1) {
				e1.printStackTrace();
			}
		}
	});
	packet_pane.setSelectedIndex(1); /* decoded */
	return packet_pane;
}
 
Example 2
Source File: RTabbedPaneTest.java    From marathonv5 with Apache License 2.0 6 votes vote down vote up
public void areWeGettingMultipleSelects() throws Throwable {
    IDevice d = Device.getDevice();
    final LoggingRecorder lr = new LoggingRecorder();
    final JTabbedPane tp = (JTabbedPane) ComponentUtils.findComponent(JTabbedPane.class, frame);
    Point p = getTabClickPoint(tp, 1);
    d.click(tp, Buttons.LEFT, 1, p.x, p.y);
    tp.addChangeListener(new ChangeListener() {
        @Override
        public void stateChanged(ChangeEvent e) {
            RTabbedPane rtp = new RTabbedPane(tp, null, null, lr);
            rtp.stateChanged(e);
        }
    });
    p = getTabClickPoint(tp, 2);
    d.click(tp, Buttons.LEFT, 1, p.x, p.y);
    AssertJUnit.assertEquals(1, lr.getCalls().size());
}
 
Example 3
Source File: MarkdownTextAreaWithPreview.java    From meka with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Initializes the widgets.
 */
@Override
protected void initGUI() {
	super.initGUI();

	setLayout(new BorderLayout());

	m_TabbedPane = new JTabbedPane();
	add(m_TabbedPane, BorderLayout.CENTER);

	m_TextCode = new JTextArea();
	m_TextCode.setFont(GUIHelper.getMonospacedFont());
	m_TabbedPane.addTab("Write", new BaseScrollPane(m_TextCode));

	m_PanePreview = new JEditorPane();
	m_PanePreview.setEditable(false);
	m_PanePreview.setContentType("text/html");
	m_TabbedPane.addTab("Preview", new BaseScrollPane(m_PanePreview));

	m_TabbedPane.addChangeListener(new ChangeListener() {
		@Override
		public void stateChanged(ChangeEvent e) {
			update();
		}
	});
}
 
Example 4
Source File: TestDataComponent.java    From Cognizant-Intelligent-Test-Scripter with Apache License 2.0 6 votes vote down vote up
private JTabbedPane createNewTestDataTab(TestData sTestData) {
    JTabbedPane testdataTab = new JTabbedPane();
    testdataTab.setTabLayoutPolicy(JTabbedPane.SCROLL_TAB_LAYOUT);
    testdataTab.setTabPlacement(JTabbedPane.BOTTOM);
    addToTab(testdataTab, sTestData.getGlobalData(), true);
    for (AbstractDataModel std : sTestData.getTestDataList()) {
        addToTab(testdataTab, std, false);
    }

    JLabel label = new JLabel("Click + to Add New TestData");
    testdataTab.addTab("", ADD_NEW_TAB_ICON, label);
    label.setHorizontalAlignment(JLabel.CENTER);
    TabTitleEditListener l = new TabTitleEditListener(testdataTab, onTestDataRenameAction(), 0);
    l.setOnMiddleClickAction(onCloseAction());
    testdataTab.addChangeListener(l);
    testdataTab.addMouseListener(l);
    testdataTab.addChangeListener(this);
    testdataTab.addMouseListener(onAddNewTDTab());
    testdataTab.setComponentPopupMenu(testDataTabPopup);
    return testdataTab;
}
 
Example 5
Source File: PreferencesWindow.java    From gcs with Mozilla Public License 2.0 6 votes vote down vote up
private PreferencesWindow() {
    super(I18n.Text("Preferences"));
    mTabPanel = new JTabbedPane();
    addTab(new SheetPreferences(this));
    addTab(new DisplayPreferences(this));
    addTab(new OutputPreferences(this));
    addTab(new FontPreferences(this));
    addTab(new MenuKeyPreferences(this));
    addTab(new ReferenceLookupPreferences(this));
    mTabPanel.addChangeListener(this);
    Container content = getContentPane();
    content.add(mTabPanel);
    content.add(createResetPanel(), BorderLayout.SOUTH);
    adjustResetButton();
    restoreBounds();
}
 
Example 6
Source File: StubsController.java    From audiveris with GNU Affero General Public License v3.0 6 votes vote down vote up
/**
 * Create the {@code StubsController} singleton.
 */
private StubsController ()
{
    stubsMap = new HashMap<>();

    stubsPane = new JTabbedPane();
    stubsPane.setForeground(Colors.SHEET_NOT_LOADED);

    // Listener on sheet tab operations
    stubsPane.addChangeListener(this);

    // Listener on invalid sheets display
    ViewParameters.getInstance().addPropertyChangeListener(
            ViewParameters.INVALID_SHEET_DISPLAY,
            this);

    // Key binding
    bindKeys();
}
 
Example 7
Source File: MainMenu.java    From COMP3204 with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * Construct the UI
 */
public MainMenu() {
	final List<LectureObject> lectures = getLectures();

	this.setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
	tabs = new JTabbedPane();
	final List<JButton> runBtns = new ArrayList<JButton>();
	for (final LectureObject l : lectures) {
		final Component lp = createLecturePanel(l, runBtns);
		tabs.addTab(l.lecture.title(), lp);
	}

	tabs.addChangeListener(new ChangeListener() {
		@Override
		public void stateChanged(ChangeEvent e) {
			final int idx = tabs.getSelectedIndex();
			final JRootPane root = MainMenu.this.getRootPane();

			if (root != null && idx >= 0)
				root.setDefaultButton(runBtns.get(idx));
		}
	});

	add(tabs);

	final JPanel info = new JPanel(new GridLayout(0, 1));
	info.setPreferredSize(new Dimension(800, 30));
	info.setSize(info.getPreferredSize());
	info.setMaximumSize(info.getPreferredSize());

	final JLabel link = Utils.linkify("http://comp3204.ecs.soton.ac.uk", "http://comp3204.ecs.soton.ac.uk",
			"Go to the course web site");
	link.setHorizontalAlignment(SwingConstants.CENTER);
	info.add(link);

	add(info);
}
 
Example 8
Source File: SheetsController.java    From libreveris with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Create the SheetsController singleton.
 */
private SheetsController ()
{
    tabbedPane = new JTabbedPane();
    assemblies = new ArrayList<>();

    // Listener on sheet tab operations
    tabbedPane.addChangeListener(this);
}
 
Example 9
Source File: EditBox.java    From jaamsim with Apache License 2.0 5 votes vote down vote up
private EditBox() {
	super( "Input Editor" );
	setDefaultCloseOperation(FrameBox.DISPOSE_ON_CLOSE);
	addWindowListener(FrameBox.getCloseListener("ShowInputEditor"));

	editTableList = new ArrayList<>();

	// Provide tabs for the editor
	jTabbedFrame = new JTabbedPane();
	jTabbedFrame.addChangeListener(new ChangeListener()  {

		@Override
		public void stateChanged(ChangeEvent e) {
			if (prevTab != -1 && editTableList.size() > prevTab) {
				final CellEditor editor = editTableList.get(prevTab).getPresentCellEditor();
				if (editor != null) {
					// Wait for a change in selected entity to take effect
					SwingUtilities.invokeLater(new Runnable() {
						@Override
						public void run() {
							editor.stopCellEditing();
						}
					});
				}
			}
			prevTab = jTabbedFrame.getSelectedIndex();
			GUIFrame.updateUI();
		}
	});
	getContentPane().add(jTabbedFrame);

	// Save changes to the editor's size and position
	addComponentListener(FrameBox.getSizePosAdapter(this, "InputEditorSize", "InputEditorPos"));
}
 
Example 10
Source File: MainMenu.java    From COMP6237 with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * Construct the UI
 */
public MainMenu() {
	final List<LectureObject> lectures = getLectures();

	this.setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
	tabs = new JTabbedPane();
	final List<JButton> runBtns = new ArrayList<JButton>();
	for (final LectureObject l : lectures) {
		final Component lp = createLecturePanel(l, runBtns);
		tabs.addTab(l.lecture.title(), lp);
	}

	tabs.addChangeListener(new ChangeListener() {
		@Override
		public void stateChanged(ChangeEvent e) {
			final int idx = tabs.getSelectedIndex();
			final JRootPane root = MainMenu.this.getRootPane();

			if (root != null && idx >= 0)
				root.setDefaultButton(runBtns.get(idx));
		}
	});

	add(tabs);

	final JPanel info = new JPanel(new GridLayout(0, 1));
	info.setPreferredSize(new Dimension(800, 30));
	info.setSize(info.getPreferredSize());
	info.setMaximumSize(info.getPreferredSize());

	final JLabel link = Utils.linkify("http://comp6237.ecs.soton.ac.uk", "http://comp6237.ecs.soton.ac.uk",
			"Go to the course web site");
	link.setHorizontalAlignment(SwingConstants.CENTER);
	info.add(link);

	add(info);
}
 
Example 11
Source File: DatabaseOperationsPanel.java    From importer-exporter with Apache License 2.0 5 votes vote down vote up
private void init() {
	setLayout(new GridBagLayout());

	workspace = new JXTextField();
	workspace.setPromptForeground(Color.LIGHT_GRAY);
	workspace.setFocusBehavior(FocusBehavior.SHOW_PROMPT);
	datePicker = new DatePicker();
	workspaceLabel = new JLabel();
	timestampLabel = new JLabel();

	add(workspaceLabel, GuiUtil.setConstraints(0,0,0.0,0.0,GridBagConstraints.BOTH,0,0,5,5));
	add(workspace, GuiUtil.setConstraints(1,0,1.0,0.0,GridBagConstraints.HORIZONTAL,0,5,5,5));
	add(timestampLabel, GuiUtil.setConstraints(2,0,0.0,0.0,GridBagConstraints.NONE,0,10,5,5));
	add(datePicker, GuiUtil.setConstraints(3,0,0.0,0.0,GridBagConstraints.HORIZONTAL,0,5,5,0));

	operationsTab = new JTabbedPane(JTabbedPane.TOP, JTabbedPane.SCROLL_TAB_LAYOUT);
	add(operationsTab, GuiUtil.setConstraints(0,2,4,1,1.0,1.0,GridBagConstraints.BOTH,5,0,0,0));

	operations = new DatabaseOperationView[]{
			new ReportOperation(this),
			new BoundingBoxOperation(this, config),
			new IndexOperation(this, config),
			new SrsOperation(this, config),
			new ADEInfoOperation(this)
	};

	for (int i = 0; i < operations.length; ++i)
		operationsTab.insertTab(null, operations[i].getIcon(), null, operations[i].getToolTip(), i);

	operationsTab.addChangeListener(e -> {
		int index = operationsTab.getSelectedIndex();
		for (int i = 0; i < operationsTab.getTabCount(); i++)
			operationsTab.setComponentAt(i, index == i ? operations[index].getViewComponent() : null);
	});

	PopupMenuDecorator.getInstance().decorate(workspace, datePicker.getEditor());
}
 
Example 12
Source File: BaseDialogImpl.java    From azure-devops-intellij with MIT License 5 votes vote down vote up
/**
 * There is a default implementation here, but subclasses can override this if they don't need tabbed pages.
 */
@Override
protected JComponent createCenterPanel() {
    tabPanel = new JTabbedPane();
    tabPanel.setPreferredSize(new Dimension(JBUI.scale(500), JBUI.scale(600)));
    tabPanel.addChangeListener(new ChangeListener() {
        @Override
        public void stateChanged(final ChangeEvent e) {
            doTabChangedAction();
        }
    });
    return tabPanel;
}
 
Example 13
Source File: PsychoTab.java    From psychoPATH with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Find our tab index within Burp's JTabbedPane. Setup an activation
 * listener that resets the title colour to black.
 */
public void findTab() {
    if(tabIndex != null)
        return;
    tabPane = (JTabbedPane) psychoPanel.getParent();
    if(tabPane == null)
        return;
    for(int i = 0; i < tabPane.getTabCount(); i++)
        if(Objects.equals(tabPane.getTitleAt(i), getTabCaption()))
            tabIndex = i;
    tabPane.addChangeListener((ChangeEvent e1) -> {
        if(tabPane.getSelectedIndex() == tabIndex)
            tabPane.setBackgroundAt(tabIndex, Color.BLACK);
    });
}
 
Example 14
Source File: DiffViewModeSwitcher.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public void setupMode (DiffController view) {
    JTabbedPane tabPane = findTabbedPane(view.getJComponent());
    if (tabPane != null) {
        if (!handledViews.containsKey(tabPane)) {
            ChangeListener list = WeakListeners.change(this, tabPane);
            handledViews.put(tabPane, list);
            tabPane.addChangeListener(list);
        }
        if (tabPane.getTabCount() > diffViewMode) {
            tabPane.setSelectedIndex(diffViewMode);
        }
    }
}
 
Example 15
Source File: SearchPanel.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private void init(Presenter explicitPresenter) {

        presenters = makePresenters(explicitPresenter);
        setLayout(new GridLayout(1, 1));

        if (presenters.isEmpty()) {
            throw new IllegalStateException("No presenter found");      //NOI18N
        } else if (presenters.size() == 1) {
            selectedPresenter = presenters.get(0).getPresenter();
            add(selectedPresenter.getForm());
        } else {
            tabbedPane = new JTabbedPane();
            for (PresenterProxy pp : presenters) {
                Component tab = tabbedPane.add(pp.getForm());
                if (pp.isInitialized()) {
                    tabbedPane.setSelectedComponent(tab);
                    selectedPresenter = pp.getPresenter();
                }
            }
            tabbedPane.addChangeListener(new ChangeListener() {
                @Override
                public void stateChanged(ChangeEvent e) {
                    tabChanged();
                }
            });
            add(tabbedPane);
        }
        if (selectedPresenter == null) {
            chooseLastUsedPresenter();
        }
        newTabCheckBox = new JCheckBox(NbBundle.getMessage(SearchPanel.class,
                "TEXT_BUTTON_NEW_TAB"));                                //NOI18N
        newTabCheckBox.setMaximumSize(new Dimension(1000, 200));
        newTabCheckBox.setSelected(
                FindDialogMemory.getDefault().isOpenInNewTab());
        initLocalStrings();
        initAccessibility();
    }
 
Example 16
Source File: EditorDockable.java    From MeteoInfo with GNU Lesser General Public License v3.0 5 votes vote down vote up
public EditorDockable(FrmMain parent, String id, String title, CAction... actions) {
    super(id, title, actions);

    this.parent = parent;
    String lfName = this.parent.getOptions().getLookFeel();
    String themeName = "default";
    switch (lfName) {
        case "FlatDarculaLaf":
        case "FlatDarkLaf":
            themeName = "dark";
            break;
    }
    try {
        theme = Theme.load(getClass().getResourceAsStream(
                "/org/fife/ui/rsyntaxtextarea/themes/" + themeName + ".xml"));
    } catch (IOException ioe) { // Never happens
        ioe.printStackTrace();
    }
    tabbedPanel = new JTabbedPane();
    tabbedPanel.addChangeListener((ChangeEvent e) -> {
        JTabbedPane sourceTabbedPane = (JTabbedPane) e.getSource();
        TextEditor te = (TextEditor) sourceTabbedPane.getSelectedComponent();
        if (te != null) {
            EditorDockable.this.setTitleText("Editor - " + te.getFileName());
        }
    });
    this.getContentPane().add(tabbedPanel);
    //this.setCloseable(false);
}
 
Example 17
Source File: ControlPanel.java    From gepard with MIT License 4 votes vote down vote up
public ControlPanel(Controller ictrl) {

		// store controller
		ctrl = ictrl;

		// load substitution matrices from XML file
		try {
			substMatrices = SubstMatrixList.getInstance().getMatrixFiles();
		} catch (Exception e) {
			ClientGlobals.errMessage("Could not open substitution matrix list. " + "The 'matrices/' subfolder seems to be corrupted");
			System.exit(1);
		}

		// sequences panel
		JPanel localTab = generateLocalTab();

		seqTabs = new JTabbedPane();
		// add sequence panes
		seqTabs.addTab("Sequences", localTab);
		seqTabs.addChangeListener(this);

		// function panel
		JPanel functPanel = generateFunctionPanel();

		// options panel
		JPanel plotOptTab = generatePlotOptTab();
		JPanel miscTab = generateMiscTab();
		dispTab = generateDispTab();

		optTabs = new JTabbedPane();
		optTabs.setFont(MAIN_FONT);
		// optTabs.setBorder(BorderFactory.createEmptyBorder());
		optTabs.addTab("Plot", plotOptTab);
		optTabs.addTab("Misc", miscTab);
		optTabs.addTab("Display", dispTab);
		optTabs.setSelectedIndex(0);

		// create layout
		seqTabs.setAlignmentX(Component.LEFT_ALIGNMENT);
		optTabs.setAlignmentX(Component.LEFT_ALIGNMENT);
		btnGo.setAlignmentX(Component.LEFT_ALIGNMENT);
		functPanel.setAlignmentX(Component.LEFT_ALIGNMENT);
		JPanel fixedBox = new JPanel();
		fixedBox.setLayout(new BoxLayout(fixedBox, BoxLayout.Y_AXIS));
		// fixedBox.setLayout(new GridBagLayout());
		fixedBox.add(Box.createRigidArea(new Dimension(0, 3)));
		fixedBox.add(seqTabs);
		fixedBox.add(Box.createRigidArea(new Dimension(0, 10)));
		fixedBox.add(functPanel);
		// fixedBox.add(Box.createRigidArea(new Dimension(0,10)));

		fixedBox.add(Box.createRigidArea(new Dimension(0, 10)));
		fixedBox.add(optTabs);

		seqTabs.setPreferredSize(new Dimension(1, SEQ_HEIGHT));
		functPanel.setPreferredSize(new Dimension(1, FUNCT_HEIGHT));
		optTabs.setPreferredSize(new Dimension(1, OPT_HEIGHT));

		// dummy panel which pushes the go button to the bottom of the window
		JPanel panelQuit = new JPanel(new GridBagLayout());
		GridBagConstraints c = new GridBagConstraints();
		c.fill = GridBagConstraints.HORIZONTAL;
		c.gridx = 0;
		c.gridy = 0;
		c.weightx = 1;
		c.weighty = 1000;
		panelQuit.add(new JLabel(""), c);
		c.gridy++;
		c.weighty = 1;
		c.insets = new Insets(0, HOR_MARGIN + QUIT_BTN_HOR_MARGIN, BELOW_QUIT_BTN, HOR_MARGIN + QUIT_BTN_HOR_MARGIN);
		panelQuit.add(btnQuit = new JButton("Quit"), c);

		btnQuit.setPreferredSize(new Dimension(1, QUIT_BTN_HEIGHT));

		setLayout(new BorderLayout());
		add(fixedBox, BorderLayout.NORTH);
		add(panelQuit, BorderLayout.CENTER);

		btnQuit.addActionListener(this);

		// simple or advanced mode
		if (Config.getInstance().getIntVal("advanced", 0) == 1)
			switchMode(true);
		else
			switchMode(false);

		// help tooltips
		btnQuit.setToolTipText(HelpTexts.getInstance().getHelpText("quit"));

		// set initial parameters
		needreload = true;

		setDispTabEnabled(false);
		setNavigationEnabled(false);

	}
 
Example 18
Source File: TypeDialog.java    From binnavi with Apache License 2.0 4 votes vote down vote up
private void createControls(final BaseType baseType) {
  if (baseType == null) {
    atomicTypePanel = new AtomicTypePanel(this, typeManager);
    pointerTypePanel = new PointerTypePanel(this, typeManager);
    arrayTypePanel = new ArrayTypePanel(this, typeManager);
    structureTypePanel = new StructureTypePanel(this, typeManager);
    unionTypePanel = new UnionTypePanel(this, typeManager);
    functionPrototypePanel = new PrototypeTypePanel(this, typeManager);
  } else {
    switch (baseType.getCategory()) {
      case ATOMIC:
        atomicTypePanel = new AtomicTypePanel(this, typeManager, baseType);
        break;
      case POINTER:
        pointerTypePanel = new PointerTypePanel(this, typeManager, baseType);
        break;
      case ARRAY:
        arrayTypePanel = new ArrayTypePanel(this, typeManager, baseType);
        break;
      case STRUCT:
        structureTypePanel = new StructureTypePanel(this, typeManager, baseType);
        break;
      case UNION:
        unionTypePanel = new UnionTypePanel(this, typeManager, baseType);
        break;
      case FUNCTION_PROTOTYPE:
        functionPrototypePanel = new PrototypeTypePanel(this, typeManager, baseType);
        break;
      default:
        throw new IllegalStateException("IE02854: Unknown type category.");
    }
  }

  tabbedPane = new JTabbedPane();
  addTab(atomicTypePanel, "Atomic type");
  addTab(pointerTypePanel, "Pointer type");
  addTab(arrayTypePanel, "Array type");
  addTab(structureTypePanel, "Structure type");
  addTab(unionTypePanel, "Union type");
  addTab(functionPrototypePanel, "Function prototype");

  tabbedPane.addChangeListener(new ChangeListener() {
    @Override
    public void stateChanged(final ChangeEvent e) {
      final JTabbedPane pane = (JTabbedPane) e.getSource();
      TypeDialog.this.currentPanel = panels.get(pane.getSelectedIndex());
    }
  });
  setActivePanel(baseType);
  setBounds(100, 100, 516, 325);
  getContentPane().setLayout(new BorderLayout());
  getContentPane().add(tabbedPane);
  createButtons();
}
 
Example 19
Source File: Dashboard.java    From computational-economy with GNU General Public License v3.0 4 votes vote down vote up
public Dashboard() {
	/*
	 * panels
	 */
	setLayout(new BorderLayout());
	setTitle("Computational Economy");

	/*
	 * border panel
	 */
	this.add(controlPanel, BorderLayout.WEST);

	/*
	 * tabbed content panel
	 */
	jTabbedPane = new JTabbedPane();
	jTabbedPane.addTab("Agents", agentsPanel);
	jTabbedPane.addTab("Households", householdsPanel);
	jTabbedPane.addTab("Industries", industriesPanel);
	jTabbedPane.addTab("Traders", tradersPanel);
	jTabbedPane.addTab("Banks", banksPanel);
	jTabbedPane.addTab("States", statesPanel);
	jTabbedPane.addTab("Money", moneyPanel);
	jTabbedPane.addTab("National Accounts", nationalAccountsPanel);
	jTabbedPane.addTab("Logs", logPanel);

	jTabbedPane.addChangeListener(new ChangeListener() {
		@Override
		public void stateChanged(final ChangeEvent e) {
			if (e.getSource() instanceof JTabbedPane) {
				final JTabbedPane pane = (JTabbedPane) e.getSource();
				final ModelListener selectedComponent = (ModelListener) pane.getSelectedComponent();
				selectedComponent.notifyListener();
			}
		}
	});

	add(jTabbedPane, BorderLayout.CENTER);

	/*
	 * Pack
	 */

	setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
	pack();
	setVisible(true);
}
 
Example 20
Source File: OpendapAccessPanel.java    From snap-desktop with GNU General Public License v3.0 4 votes vote down vote up
private void initComponents() {
    urlField = new JComboBox<>();
    urlField.setEditable(true);
    urlField.getEditor().getEditorComponent().addKeyListener(new KeyAdapter() {
        @Override
        public void keyTyped(KeyEvent e) {
            if (e.getKeyChar() == KeyEvent.VK_ENTER) {
                refreshButton.doClick();
            }
        }
    });
    updateUrlField();
    refreshButton = ToolButtonFactory.createButton(
            TangoIcons.actions_view_refresh(TangoIcons.Res.R22),
            false);
    refreshButton.addActionListener(e -> {
        final boolean usingUrl = refresh();
        if (usingUrl) {
            final String urls = preferences.get(PROPERTY_KEY_SERVER_URLS, "");
            final String currentUrl = urlField.getSelectedItem().toString();
            if (!urls.contains(currentUrl)) {
                preferences.put(PROPERTY_KEY_SERVER_URLS, urls + "\n" + currentUrl);
                updateUrlField();
            }
        }
    });
    metaInfoArea = new JTabbedPane(JTabbedPane.TOP, JTabbedPane.SCROLL_TAB_LAYOUT);
    JTextArea ddsArea = new JTextArea(10, 40);
    JTextArea dasArea = new JTextArea(10, 40);

    ddsArea.setEditable(false);
    dasArea.setEditable(false);

    textAreas = new HashMap<>();
    textAreas.put(DAS_AREA_INDEX, dasArea);
    textAreas.put(DDS_AREA_INDEX, ddsArea);

    metaInfoArea.addTab("DDS", new JScrollPane(ddsArea));
    metaInfoArea.addTab("DAS", new JScrollPane(dasArea));
    metaInfoArea.setToolTipTextAt(DDS_AREA_INDEX, "Dataset Descriptor Structure: description of dataset variables");
    metaInfoArea.setToolTipTextAt(DAS_AREA_INDEX, "Dataset Attribute Structure: description of dataset attributes");

    metaInfoArea.addChangeListener(e -> {
        if (catalogTree.getSelectedLeaf() != null) {
            setMetadataText(metaInfoArea.getSelectedIndex(), catalogTree.getSelectedLeaf());
        }
    });

    catalogTree = new CatalogTree(new DefaultLeafSelectionListener(), appContext, this);
    useDatasetNameFilter = new JCheckBox("Use dataset name filter");
    useTimeRangeFilter = new JCheckBox("Use time range filter");
    useRegionFilter = new JCheckBox("Use region filter");
    useVariableFilter = new JCheckBox("Use variable name filter");

    DefaultFilterChangeListener filterChangeListener = new DefaultFilterChangeListener();
    datasetNameFilter = new DatasetNameFilter(useDatasetNameFilter);
    datasetNameFilter.addFilterChangeListener(filterChangeListener);
    timeRangeFilter = new TimeRangeFilter(useTimeRangeFilter);
    timeRangeFilter.addFilterChangeListener(filterChangeListener);
    regionFilter = new RegionFilter(useRegionFilter);
    regionFilter.addFilterChangeListener(filterChangeListener);
    variableFilter = new VariableFilter(useVariableFilter, catalogTree);
    variableFilter.addFilterChangeListener(filterChangeListener);

    catalogTree.addCatalogTreeListener(new CatalogTree.CatalogTreeListener() {
        @Override
        public void leafAdded(OpendapLeaf leaf, boolean hasNestedDatasets) {
            if (hasNestedDatasets) {
                return;
            }
            if (leaf.getDataset().getGeospatialCoverage() != null) {
                useRegionFilter.setEnabled(true);
            }
            filterLeaf(leaf);
        }

        @Override
        public void catalogElementsInsertionFinished() {
        }
    });

    openInVisat = new JCheckBox("Open in SNAP");
    statusBarMessage = new JLabel("Ready.");
    statusBarMessage.setText("Ready.");
    preMessageLabel = new JLabel();
    postMessageLabel = new JLabel();
    progressBar = new JProgressBar(0, 100);

    statusBar = new JPanel();
    statusBar.setLayout(new BoxLayout(statusBar, BoxLayout.X_AXIS));
    statusBar.add(statusBarMessage);
    statusBar.add(Box.createHorizontalStrut(4));
    statusBar.add(preMessageLabel);
    statusBar.add(Box.createHorizontalGlue());
    statusBar.add(progressBar);
    statusBar.add(Box.createHorizontalGlue());
    statusBar.add(postMessageLabel);

    useRegionFilter.setEnabled(false);
}