Example usage for javax.swing ListSelectionModel setSelectionMode

List of usage examples for javax.swing ListSelectionModel setSelectionMode

Introduction

In this page you can find the example usage for javax.swing ListSelectionModel setSelectionMode.

Prototype

void setSelectionMode(int selectionMode);

Source Link

Document

Sets the selection mode.

Usage

From source file:simx.profiler.info.application.ActorsInfoTopComponent.java

public ActorsInfoTopComponent() {
    initComponents();//from   w w w  .ja va2 s .  c  om
    setName(Bundle.CTL_ActorsInfoTopComponent());
    setToolTipText(Bundle.HINT_ActorsInfoTopComponent());

    this.content = new InstanceContent();

    this.associateLookup(new AbstractLookup(this.content));

    this.profilingData = ProfilingData.getLoadedProfilingData();
    final Map<MessageType, Integer> applicationCommunicationDataLocal = new HashMap<>();
    this.profilingData.getMessageTypes().stream().forEach((messageType) -> {
        applicationCommunicationDataLocal.put(messageType, messageType.getTimesSent());
    });
    this.applicationCommunicationData = new CommunicationData(new ImmutableTupel<>(null, null),
            applicationCommunicationDataLocal);
    this.content.set(Collections.singleton(this.applicationCommunicationData), null);

    this.actorTypes = this.profilingData.getActorTypes();
    this.actorTypeInformationTable.setModel(new ActorTypeInformationTableModel(this.profilingData));
    ListSelectionModel listSelectionModel = this.actorTypeInformationTable.getSelectionModel();
    listSelectionModel.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    listSelectionModel.addListSelectionListener((final ListSelectionEvent e) -> {
        setSelectedActorType(actorTypes.get(actorTypeInformationTable.getSelectedRow()));
    });
    this.actorInstances = profilingData.getActorInstances();
    listSelectionModel = this.actorInstanceInformationTable.getSelectionModel();
    listSelectionModel.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    listSelectionModel.addListSelectionListener((ListSelectionEvent e) -> {
        final ActorInstance actorInstance = actorInstances.get(actorInstanceInformationTable.getSelectedRow());
        setSelectedActorInstance(actorInstance);
    });
    this.actorInstanceInformationTable.setModel(new ActorInstanceInformationTableModel(this.profilingData));

    long minProcessingTime = Long.MAX_VALUE;
    long maxProcessingTime = Long.MIN_VALUE;

    for (final ActorType type : this.actorTypes) {
        if (type.getOverallProcessingTime() < minProcessingTime)
            minProcessingTime = type.getOverallProcessingTime();
        if (type.getOverallProcessingTime() > maxProcessingTime)
            maxProcessingTime = type.getOverallProcessingTime();
    }

    final Map<ImmutableTupel<ActorType, ActorType>, Integer> typeCommunicationScaleFactors = new HashMap<>();
    int minMessagesCount = Integer.MAX_VALUE;
    int maxMessagesCount = Integer.MIN_VALUE;
    for (final ActorType actorType : this.actorTypes) {
        final Map<ActorType, Map<MessageType, Integer>> s = actorType.getReceiverStatistics();
        for (final Map.Entry<ActorType, Map<MessageType, Integer>> e : s.entrySet()) {
            int count = 0;
            count = e.getValue().entrySet().stream().map((d) -> d.getValue()).reduce(count, Integer::sum);
            typeCommunicationScaleFactors.put(new ImmutableTupel<>(actorType, e.getKey()), count);
            if (count < minMessagesCount)
                minMessagesCount = count;
            if (count > maxMessagesCount)
                maxMessagesCount = count;
        }
    }

    int messagesSpan = maxMessagesCount - minMessagesCount;
    for (final Map.Entry<ImmutableTupel<ActorType, ActorType>, Integer> e : typeCommunicationScaleFactors
            .entrySet()) {
        final int factor = (((e.getValue() - minMessagesCount) * 4) / messagesSpan) + 1;
        typeCommunicationScaleFactors.put(e.getKey(), factor);
    }

    double timeSpan = maxProcessingTime - minProcessingTime;

    final Map<ActorType, Double> typeComputationScaleFactors = new HashMap<>();
    for (final ActorType type : this.actorTypes) {
        typeComputationScaleFactors.put(type,
                ((double) (type.getOverallProcessingTime() - minProcessingTime) * 0.4 / timeSpan) + 0.6);
    }

    final ActorTypeGraphScene actorTypeGraphScene = new ActorTypeGraphScene(this, typeComputationScaleFactors,
            typeCommunicationScaleFactors);
    actorTypeGraphScene.addObjectSceneListener(new ObjectSceneListener() {

        @Override
        public void objectAdded(final ObjectSceneEvent ose, final Object o) {
        }

        @Override
        public void objectRemoved(final ObjectSceneEvent ose, final Object o) {
        }

        @Override
        public void objectStateChanged(final ObjectSceneEvent ose, final Object o, final ObjectState os,
                final ObjectState os1) {
        }

        @Override
        public void selectionChanged(final ObjectSceneEvent ose, final Set<Object> oldSelection,
                final Set<Object> newSelection) {
            boolean communicationDataSet = false;
            for (final Object o : newSelection) {
                if (o instanceof ActorType)
                    setSelectedActorType((ActorType) o);
                if (o instanceof CommunicationData) {
                    setSelectedCommunicationData((CommunicationData) o);
                    communicationDataSet = true;
                }
            }
            if (!communicationDataSet)
                setSelectedCommunicationData(null);
        }

        @Override
        public void highlightingChanged(final ObjectSceneEvent ose, final Set<Object> set,
                final Set<Object> set1) {
        }

        @Override
        public void hoverChanged(final ObjectSceneEvent ose, final Object o, final Object o1) {
        }

        @Override
        public void focusChanged(final ObjectSceneEvent ose, final Object o, final Object o1) {
        }
    }, ObjectSceneEventType.OBJECT_SELECTION_CHANGED);
    this.typeScrollPane.setViewportView(actorTypeGraphScene.createView());

    this.actorTypes.stream().forEach((actorType) -> {
        actorTypeGraphScene.addNode(actorType);
    });
    this.actorTypes.stream().forEach((actorType) -> {
        final Map<ActorType, Map<MessageType, Integer>> s = actorType.getReceiverStatistics();
        s.entrySet().stream().forEach((e) -> {
            final CommunicationData edge = new CommunicationData(new ImmutableTupel<>(actorType, e.getKey()),
                    e.getValue());
            actorTypeGraphScene.addEdge(edge);
            actorTypeGraphScene.setEdgeSource(edge, actorType);
            actorTypeGraphScene.setEdgeTarget(edge, e.getKey());
        });
    });

    minProcessingTime = Long.MAX_VALUE;
    maxProcessingTime = Long.MIN_VALUE;

    for (final ActorInstance instance : this.actorInstances) {
        if (instance.getOverallProcessingTime() < minProcessingTime)
            minProcessingTime = instance.getOverallProcessingTime();
        if (instance.getOverallProcessingTime() > maxProcessingTime)
            maxProcessingTime = instance.getOverallProcessingTime();
    }

    timeSpan = maxProcessingTime - minProcessingTime;

    final Map<ImmutableTupel<ActorInstance, ActorInstance>, Integer> instanceCommunicationScaleFactors = new HashMap<>();
    minMessagesCount = Integer.MAX_VALUE;
    maxMessagesCount = Integer.MIN_VALUE;
    for (final ActorInstance instance : this.actorInstances) {
        final Map<ActorInstance, Map<MessageType, Integer>> s = instance.getReceiverStatistics();
        for (final Map.Entry<ActorInstance, Map<MessageType, Integer>> e : s.entrySet()) {
            int count = 0;
            count = e.getValue().entrySet().stream().map((d) -> d.getValue()).reduce(count, Integer::sum);
            instanceCommunicationScaleFactors.put(new ImmutableTupel<>(instance, e.getKey()), count);
            if (count < minMessagesCount)
                minMessagesCount = count;
            if (count > maxMessagesCount)
                maxMessagesCount = count;
        }
    }

    messagesSpan = maxMessagesCount - minMessagesCount;
    for (final Map.Entry<ImmutableTupel<ActorInstance, ActorInstance>, Integer> e : instanceCommunicationScaleFactors
            .entrySet()) {
        final int factor = (((e.getValue() - minMessagesCount) * 4) / messagesSpan) + 1;
        instanceCommunicationScaleFactors.put(e.getKey(), factor);
    }

    final Map<ActorInstance, Double> instanceComputationScaleFactors = new HashMap<>();
    for (final ActorInstance instance : this.actorInstances) {
        instanceComputationScaleFactors.put(instance,
                ((double) (instance.getOverallProcessingTime() - minProcessingTime) * 0.4 / timeSpan) + 0.6);
    }
    final ActorInstanceGraphScene actorInstanceGraphScene = new ActorInstanceGraphScene(this,
            instanceComputationScaleFactors, instanceCommunicationScaleFactors);

    actorInstanceGraphScene.addObjectSceneListener(new ObjectSceneListener() {

        @Override
        public void objectAdded(final ObjectSceneEvent ose, final Object o) {
        }

        @Override
        public void objectRemoved(final ObjectSceneEvent ose, final Object o) {
        }

        @Override
        public void objectStateChanged(final ObjectSceneEvent ose, final Object o, final ObjectState os,
                final ObjectState os1) {
        }

        @Override
        public void selectionChanged(final ObjectSceneEvent ose, final Set<Object> oldSelection,
                final Set<Object> newSelection) {
            boolean communicationDataSet = false;
            for (final Object o : newSelection) {
                if (o instanceof ActorInstance)
                    setSelectedActorInstance((ActorInstance) o);
                if (o instanceof CommunicationData) {
                    setSelectedCommunicationData((CommunicationData) o);
                    communicationDataSet = true;
                }
            }
            if (!communicationDataSet)
                setSelectedCommunicationData(null);
        }

        @Override
        public void highlightingChanged(final ObjectSceneEvent ose, final Set<Object> set,
                final Set<Object> set1) {
        }

        @Override
        public void hoverChanged(final ObjectSceneEvent ose, final Object o, final Object o1) {
        }

        @Override
        public void focusChanged(final ObjectSceneEvent ose, final Object o, final Object o1) {
        }
    }, ObjectSceneEventType.OBJECT_SELECTION_CHANGED);

    this.instancesScrollPane.setViewportView(actorInstanceGraphScene.createView());
    this.actorInstances.stream().forEach((actorInstance) -> {
        actorInstanceGraphScene.addNode(actorInstance);
    });
    this.actorInstances.stream().forEach((actorInstance) -> {
        final Map<ActorInstance, Map<MessageType, Integer>> s = actorInstance.getReceiverStatistics();
        s.entrySet().stream().forEach((e) -> {
            final CommunicationData edge = new CommunicationData(
                    new ImmutableTupel<>(actorInstance, e.getKey()), e.getValue());
            actorInstanceGraphScene.addEdge(edge);
            actorInstanceGraphScene.setEdgeSource(edge, actorInstance);
            actorInstanceGraphScene.setEdgeTarget(edge, e.getKey());
        });
    });

    this.dopPlotData = new XYSeriesCollection();
    JFreeChart dopChart = ChartFactory.createXYLineChart("", "", "", this.dopPlotData);
    final ChartPanel dopChartPanel = new ChartPanel(dopChart);
    dopChartPanel.setPreferredSize(new java.awt.Dimension(261, 157));
    this.dopPanel.setLayout(new BorderLayout());
    this.dopPanel.add(dopChartPanel, BorderLayout.CENTER);

    final XYSeries plotData = new XYSeries("Degree of Parallelism");

    final List<ParallelismEvent> parallelismEvents = this.profilingData.getParallelismEvents();
    Collections.sort(parallelismEvents);
    int parallelismLevel = 1;
    long lastTimeStamp = parallelismEvents.get(0).timestamp;
    final long firstTimeStamp = lastTimeStamp;
    final Map<Integer, Long> histogramData = new HashMap<>();
    plotData.add(0, 1);
    for (int i = 1; i < parallelismEvents.size(); ++i) {
        if (histogramData.containsKey(parallelismLevel)) {
            final long old = histogramData.get(parallelismLevel);
            histogramData.put(parallelismLevel, parallelismEvents.get(i).timestamp - lastTimeStamp + old);
        } else {
            histogramData.put(parallelismLevel, parallelismEvents.get(i).timestamp - lastTimeStamp);
        }
        lastTimeStamp = parallelismEvents.get(i).timestamp;
        if (parallelismEvents.get(i).eventType == ParallelismEvent.ParallelimEventTypes.PROCESSING_START) {
            ++parallelismLevel;
        } else {
            --parallelismLevel;
        }
        plotData.add((double) (lastTimeStamp - firstTimeStamp) / 1000000000.0, parallelismLevel);
    }
    this.dopPlotData.addSeries(plotData);
    this.parallelismHistogramDataSet = new DefaultCategoryDataset();

    double avgParallelism1 = 0.0;
    double avgParallelism2 = 0.0;
    long t = 0;

    for (int i = 1; i < histogramData.size(); ++i) {
        t += histogramData.get(i);
    }

    for (int i = 0; i < histogramData.size(); ++i) {
        parallelismHistogramDataSet.addValue((double) histogramData.get(i) / 1000000.0, "",
                i == 0 ? "Idle" : "" + i);
        avgParallelism1 += i * ((double) histogramData.get(i) / this.profilingData.applicationRunTime());
        avgParallelism2 += i * ((double) histogramData.get(i) / t);
    }

    final JFreeChart chart = ChartFactory.createBarChart("", "Parallelism", "ms",
            this.parallelismHistogramDataSet, PlotOrientation.VERTICAL, false, true, false);
    final ChartPanel chartPanel = new ChartPanel(chart);
    this.parallelismHistogramPanel.setLayout(new BorderLayout());
    this.parallelismHistogramPanel.add(chartPanel, BorderLayout.CENTER);

    this.runtimeTextField.setText("" + (this.profilingData.applicationRunTime() / 1000000.0));
    this.computationTimeMsTextField.setText("" + (this.profilingData.getOverallProcessingTime() / 1000000.0));
    this.computationTimePercentTextField.setText("" + (this.profilingData.getOverallProcessingTime() * 100.0
            / this.profilingData.applicationRunTime()));
    this.actorInstancesTextField.setText("" + this.actorInstances.size());
    this.messagesSentTextField.setText("" + this.profilingData.getMessagesSentCount());
    this.messagesSentPerSecondTextField.setText("" + ((double) this.profilingData.getMessagesSentCount()
            * 1000000000.0 / this.profilingData.applicationRunTime()));
    this.messagesProcessedTextField.setText("" + this.profilingData.getMessagesProcessedCount());
    this.messagesProcessedPerSecondTextField
            .setText("" + ((double) this.profilingData.getMessagesProcessedCount() * 1000000000.0
                    / this.profilingData.applicationRunTime()));
    this.averageTimeInMailboxTextField.setText("" + (this.profilingData.getAverageTimeInMailbox() / 1000000.0));
    this.avgParallelismWithIdleTimeTextField.setText("" + avgParallelism1);
    this.avgParallelismWithouIdleTimeTextField.setText("" + avgParallelism2);

    final SpawnTreeGraphScene spawnTreeGraphScene = new SpawnTreeGraphScene(this);
    this.spawnTreeScrollPane.setViewportView(spawnTreeGraphScene.createView());

    this.actorInstances.stream().forEach((actorInstance) -> {
        spawnTreeGraphScene.addNode(actorInstance);
    });
    for (final ActorInstance actorInstance : this.actorInstances) {
        if (actorInstance.supervisor != null) {
            final ImmutableTupel<ActorInstance, ActorInstance> edge = new ImmutableTupel(
                    actorInstance.supervisor, actorInstance);
            spawnTreeGraphScene.addEdge(edge);
            spawnTreeGraphScene.setEdgeSource(edge, actorInstance.supervisor);
            spawnTreeGraphScene.setEdgeTarget(edge, actorInstance);
        }
    }
}

From source file:org.fhcrc.cpl.viewer.quant.gui.ProteinQuantSummaryFrame.java

License:asdf

/**
 * Initialize the GUI components//from  w ww  . j a v  a  2 s  .c  om
 */
protected void initGUI() {
    //Global stuff
    setSize(fullWidth, fullHeight);

    eventPropertiesTable = new QuantEvent.QuantEventPropertiesTable();
    eventPropertiesTable.setVisible(true);
    JScrollPane eventPropsScrollPane = new JScrollPane();
    eventPropsScrollPane.setViewportView(eventPropertiesTable);
    eventPropsScrollPane.setSize(propertiesWidth, propertiesHeight);
    eventPropertiesDialog = new JDialog(this, "Event Properties");
    eventPropertiesDialog.setDefaultCloseOperation(JDialog.HIDE_ON_CLOSE);
    eventPropertiesDialog.setSize(propertiesWidth, propertiesHeight);
    eventPropertiesDialog.setContentPane(eventPropsScrollPane);

    ListenerHelper helper = new ListenerHelper(this);
    setTitle("Protein Summary");
    setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);

    GridBagConstraints gbc = new GridBagConstraints();
    gbc.fill = GridBagConstraints.BOTH;
    gbc.anchor = GridBagConstraints.PAGE_START;
    gbc.gridwidth = GridBagConstraints.REMAINDER;
    gbc.insets = new Insets(5, 5, 5, 5);
    gbc.weighty = 1;
    gbc.weightx = 1;

    try {
        (getOwner()).setIconImage(ImageIO.read(WorkbenchFrame.class.getResourceAsStream("icon.gif")));
    } catch (Exception e) {
    }

    try {
        Localizer.renderSwixml("org/fhcrc/cpl/viewer/quant/gui/ProteinQuantSummaryFrame.xml", this);
        assert null != contentPanel;
        setContentPane(contentPanel);
    } catch (Exception x) {
        ApplicationContext.errorMessage("error creating dialog", x);
        throw new RuntimeException(x);
    }

    buttonSelectAllVisible.setEnabled(false);
    helper.addListener(buttonSelectAllVisible, "buttonSelectAllVisible_actionPerformed");
    buttonDeselectAll.setEnabled(false);
    helper.addListener(buttonDeselectAll, "buttonDeselectAll_actionPerformed");

    buildTurkHITsButton.setEnabled(false);
    helper.addListener(buildTurkHITsButton, "buttonBuildTurkHITs_actionPerformed");
    loadSelectedEventsButton.setEnabled(false);
    helper.addListener(loadSelectedEventsButton, "buttonLoadSelected_actionPerformed");
    autoAssessSelectedEventsButton.setEnabled(false);
    helper.addListener(autoAssessSelectedEventsButton, "buttonAutoAssess_actionPerformed");

    showPropertiesButton.setEnabled(false);
    helper.addListener(showPropertiesButton, "buttonShowProperties_actionPerformed");
    showProteinRatiosButton.setEnabled(false);
    helper.addListener(showProteinRatiosButton, "buttonShowProteinRatios_actionPerformed");

    //summary panel
    summaryPanel.setBorder(BorderFactory.createLineBorder(Color.gray));
    summaryPanel.setPreferredSize(new Dimension(fullWidth, summaryPanelHeight));
    summaryPanel.setMinimumSize(new Dimension(200, summaryPanelHeight));
    gbc.fill = GridBagConstraints.NONE;

    gbc.gridwidth = 1;
    summaryPanel.add(buttonSelectAllVisible, gbc);
    summaryPanel.add(buttonDeselectAll, gbc);
    gbc.gridwidth = GridBagConstraints.RELATIVE;
    summaryPanel.add(showPropertiesButton, gbc);
    gbc.gridwidth = GridBagConstraints.REMAINDER;
    summaryPanel.add(showProteinRatiosButton, gbc);

    gbc.gridwidth = 1;

    summaryPanel.add(loadSelectedEventsButton, gbc);
    gbc.gridwidth = GridBagConstraints.RELATIVE;
    summaryPanel.add(autoAssessSelectedEventsButton, gbc);
    gbc.gridwidth = GridBagConstraints.REMAINDER;
    summaryPanel.add(buildTurkHITsButton, gbc);

    gbc.fill = GridBagConstraints.BOTH;

    eventsScrollPane = new JScrollPane();
    eventsScrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    eventsScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);

    eventsPanel = new JPanel();
    eventsPanel.setLayout(new GridBagLayout());

    eventsTable = new QuantEventsSummaryTable();
    eventsTable.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
    eventsTable.getSelectionModel().addListSelectionListener(new EventsTableListSelectionHandler());
    eventsScrollPane.setViewportView(eventsTable);
    eventsScrollPane.setMinimumSize(new Dimension(400, 400));

    gbc.insets = new Insets(0, 0, 0, 0);
    mainPanel.add(eventsScrollPane, gbc);

    logRatioHistogramPanel = new PanelWithLogRatioHistAndFields();
    logRatioHistogramPanel.setBorder(BorderFactory.createTitledBorder("Log Ratios"));
    logRatioHistogramPanel.setPreferredSize(new Dimension(width - 10, 300));
    gbc.fill = GridBagConstraints.BOTH;
    gbc.weighty = 100;
    gbc.gridwidth = GridBagConstraints.REMAINDER;
    add(logRatioHistogramPanel, gbc);

    //status message
    messageLabel = new JLabel();
    messageLabel.setBackground(Color.WHITE);
    messageLabel.setFont(Font.decode("verdana plain 12"));
    messageLabel.setText(" ");
    statusPanel = new JPanel();
    gbc.weighty = 1;
    statusPanel.setPreferredSize(new Dimension(width - 10, 50));
    statusPanel.add(messageLabel, gbc);
    add(statusPanel, gbc);

    //per-protein event summary table; disembodied
    //todo: move this into its own class? it's getting kind of complicated
    proteinRatiosTable = new JTable();
    proteinRatiosTable.setVisible(true);
    ListSelectionModel proteinTableSelectionModel = proteinRatiosTable.getSelectionModel();
    proteinTableSelectionModel.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    proteinTableSelectionModel.addListSelectionListener(new ProteinTableListSelectionHandler());
    JScrollPane proteinRatiosScrollPane = new JScrollPane();
    proteinRatiosScrollPane.setViewportView(proteinRatiosTable);
    proteinRatiosScrollPane.setPreferredSize(new Dimension(proteinDialogWidth,
            proteinDialogHeight - PROTEINTABLE_HISTPANEL_HEIGHT - PROTEINTABLE_SCATTERPLOTPANEL_HEIGHT - 70));
    proteinRatiosDialog = new JDialog(this, "Protein Ratios");
    proteinRatiosDialog.setDefaultCloseOperation(JDialog.HIDE_ON_CLOSE);
    proteinRatiosDialog.setSize(proteinDialogWidth, proteinDialogHeight);
    JPanel proteinRatiosContentPanel = new JPanel();
    gbc.gridwidth = GridBagConstraints.REMAINDER;
    gbc.fill = GridBagConstraints.BOTH;
    proteinRatiosContentPanel.add(proteinRatiosScrollPane, gbc);
    proteinRatiosDialog.setContentPane(proteinRatiosContentPanel);
    perProteinLogRatioHistogramPanel = new PanelWithLogRatioHistAndFields();
    perProteinLogRatioHistogramPanel.addRangeUpdateListener(new ProteinTableLogRatioHistogramListener());

    perProteinLogRatioHistogramPanel.setBorder(BorderFactory.createTitledBorder("Log Ratios"));
    perProteinLogRatioHistogramPanel
            .setPreferredSize(new Dimension(proteinDialogWidth - 10, PROTEINTABLE_HISTPANEL_HEIGHT));
    gbc.fill = GridBagConstraints.BOTH;
    gbc.gridwidth = GridBagConstraints.REMAINDER;
    proteinRatiosDialog.add(perProteinLogRatioHistogramPanel, gbc);

    perProteinPeptideLogRatioPanel = new JPanel();
    perProteinPeptideLogRatioPanel.setBorder(BorderFactory.createTitledBorder("By Peptide"));
    perProteinPeptideLogRatioPanel
            .setPreferredSize(new Dimension(proteinDialogWidth - 10, PROTEINTABLE_SCATTERPLOTPANEL_HEIGHT));
    proteinRatiosDialog.add(perProteinPeptideLogRatioPanel, gbc);
}

From source file:jp.massbank.spectrumsearch.SearchPage.java

/**
 * ?//  w w w. j a v a2s.c  o m
 */
private void createWindow() {

    // ??
    ToolTipManager ttm = ToolTipManager.sharedInstance();
    ttm.setInitialDelay(50);
    ttm.setDismissDelay(8000);

    // Search?
    JPanel mainPanel = new JPanel();
    mainPanel.setLayout(new BorderLayout());
    Border border = BorderFactory.createCompoundBorder(BorderFactory.createEtchedBorder(),
            new EmptyBorder(1, 1, 1, 1));
    mainPanel.setBorder(border);

    // *********************************************************************
    // User File Query
    // *********************************************************************
    DefaultTableModel fileDm = new DefaultTableModel();
    fileSorter = new TableSorter(fileDm, TABLE_QUERY_FILE);
    queryFileTable = new JTable(fileSorter) {
        @Override
        public boolean isCellEditable(int row, int column) {
            //            super.isCellEditable(row, column);
            // ??????
            return false;
        }
    };
    queryFileTable.addMouseListener(new TblMouseListener());
    fileSorter.setTableHeader(queryFileTable.getTableHeader());
    queryFileTable.setRowSelectionAllowed(true);
    queryFileTable.setColumnSelectionAllowed(false);
    queryFileTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);

    String[] col = { COL_LABEL_NO, COL_LABEL_NAME, COL_LABEL_ID };
    ((DefaultTableModel) fileSorter.getTableModel()).setColumnIdentifiers(col);
    (queryFileTable.getColumn(queryFileTable.getColumnName(0))).setPreferredWidth(44);
    (queryFileTable.getColumn(queryFileTable.getColumnName(1))).setPreferredWidth(LEFT_PANEL_WIDTH - 44);
    (queryFileTable.getColumn(queryFileTable.getColumnName(2))).setPreferredWidth(70);

    ListSelectionModel lm = queryFileTable.getSelectionModel();
    lm.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    lm.addListSelectionListener(new LmFileListener());
    queryFilePane = new JScrollPane(queryFileTable);
    queryFilePane.addMouseListener(new PaneMouseListener());
    queryFilePane.setPreferredSize(new Dimension(300, 300));

    // *********************************************************************
    // Result
    // *********************************************************************
    DefaultTableModel resultDm = new DefaultTableModel();
    resultSorter = new TableSorter(resultDm, TABLE_RESULT);
    resultTable = new JTable(resultSorter) {
        @Override
        public String getToolTipText(MouseEvent me) {
            //            super.getToolTipText(me);
            // ?????
            Point pt = me.getPoint();
            int row = rowAtPoint(pt);
            if (row < 0) {
                return null;
            } else {
                int nameCol = getColumnModel().getColumnIndex(COL_LABEL_NAME);
                return " " + getValueAt(row, nameCol) + " ";
            }
        }

        @Override
        public boolean isCellEditable(int row, int column) {
            //            super.isCellEditable(row, column);
            // ??????
            return false;
        }
    };
    resultTable.addMouseListener(new TblMouseListener());
    resultSorter.setTableHeader(resultTable.getTableHeader());

    JPanel dbPanel = new JPanel();
    dbPanel.setLayout(new BorderLayout());
    resultPane = new JScrollPane(resultTable);
    resultPane.addMouseListener(new PaneMouseListener());

    resultTable.setRowSelectionAllowed(true);
    resultTable.setColumnSelectionAllowed(false);
    resultTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);

    String[] col2 = { COL_LABEL_NAME, COL_LABEL_SCORE, COL_LABEL_HIT, COL_LABEL_ID, COL_LABEL_ION,
            COL_LABEL_CONTRIBUTOR, COL_LABEL_NO };

    resultDm.setColumnIdentifiers(col2);
    (resultTable.getColumn(resultTable.getColumnName(0))).setPreferredWidth(LEFT_PANEL_WIDTH - 180);
    (resultTable.getColumn(resultTable.getColumnName(1))).setPreferredWidth(70);
    (resultTable.getColumn(resultTable.getColumnName(2))).setPreferredWidth(20);
    (resultTable.getColumn(resultTable.getColumnName(3))).setPreferredWidth(70);
    (resultTable.getColumn(resultTable.getColumnName(4))).setPreferredWidth(20);
    (resultTable.getColumn(resultTable.getColumnName(5))).setPreferredWidth(70);
    (resultTable.getColumn(resultTable.getColumnName(6))).setPreferredWidth(50);

    ListSelectionModel lm2 = resultTable.getSelectionModel();
    lm2.addListSelectionListener(new LmResultListener());

    resultPane.setPreferredSize(new Dimension(LEFT_PANEL_WIDTH, 200));
    dbPanel.add(resultPane, BorderLayout.CENTER);

    // *********************************************************************
    // DB Query
    // *********************************************************************
    DefaultTableModel dbDm = new DefaultTableModel();
    querySorter = new TableSorter(dbDm, TABLE_QUERY_DB);
    queryDbTable = new JTable(querySorter) {
        @Override
        public boolean isCellEditable(int row, int column) {
            //            super.isCellEditable(row, column);
            // ??????
            return false;
        }
    };
    queryDbTable.addMouseListener(new TblMouseListener());
    querySorter.setTableHeader(queryDbTable.getTableHeader());
    queryDbPane = new JScrollPane(queryDbTable);
    queryDbPane.addMouseListener(new PaneMouseListener());

    int h = (int) Toolkit.getDefaultToolkit().getScreenSize().getHeight();
    queryDbPane.setPreferredSize(new Dimension(LEFT_PANEL_WIDTH, h));
    queryDbTable.setRowSelectionAllowed(true);
    queryDbTable.setColumnSelectionAllowed(false);
    queryDbTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);

    String[] col3 = { COL_LABEL_ID, COL_LABEL_NAME, COL_LABEL_CONTRIBUTOR, COL_LABEL_NO };
    DefaultTableModel model = (DefaultTableModel) querySorter.getTableModel();
    model.setColumnIdentifiers(col3);

    // 
    queryDbTable.getColumn(queryDbTable.getColumnName(0)).setPreferredWidth(70);
    queryDbTable.getColumn(queryDbTable.getColumnName(1)).setPreferredWidth(LEFT_PANEL_WIDTH - 70);
    queryDbTable.getColumn(queryDbTable.getColumnName(2)).setPreferredWidth(70);
    queryDbTable.getColumn(queryDbTable.getColumnName(3)).setPreferredWidth(50);

    ListSelectionModel lm3 = queryDbTable.getSelectionModel();
    lm3.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    lm3.addListSelectionListener(new LmQueryDbListener());

    // ?
    JPanel btnPanel = new JPanel();
    btnName.addActionListener(new BtnSearchNameListener());
    btnAll.addActionListener(new BtnAllListener());
    btnPanel.add(btnName);
    btnPanel.add(btnAll);

    parentPanel2 = new JPanel();
    parentPanel2.setLayout(new BoxLayout(parentPanel2, BoxLayout.PAGE_AXIS));
    parentPanel2.add(btnPanel);
    parentPanel2.add(queryDbPane);

    // ?
    JPanel dispModePanel = new JPanel();
    isDispSelected = dispSelected.isSelected();
    isDispRelated = dispRelated.isSelected();
    if (isDispSelected) {
        resultTable.getSelectionModel().setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
    } else if (isDispRelated) {
        resultTable.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    }
    Object[] retRadio = new Object[] { dispSelected, dispRelated };
    for (int i = 0; i < retRadio.length; i++) {
        ((JRadioButton) retRadio[i]).addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent arg0) {
                if (isDispSelected != dispSelected.isSelected() || isDispRelated != dispRelated.isSelected()) {

                    isDispSelected = dispSelected.isSelected();
                    isDispRelated = dispRelated.isSelected();

                    // ??
                    resultTable.clearSelection();
                    resultPlot.clear();
                    compPlot.setPeaks(null, 1);
                    resultPlot.setPeaks(null, 0);
                    setAllPlotAreaRange();
                    pkgView.initResultRecInfo();

                    if (isDispSelected) {
                        resultTable.getSelectionModel()
                                .setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
                    } else if (isDispRelated) {
                        resultTable.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
                    }
                }
            }
        });
    }
    ButtonGroup disGroup = new ButtonGroup();
    disGroup.add(dispSelected);
    disGroup.add(dispRelated);
    dispModePanel.add(lbl2);
    dispModePanel.add(dispSelected);
    dispModePanel.add(dispRelated);

    JPanel paramPanel = new JPanel();
    paramPanel.add(etcPropertyButton);
    etcPropertyButton.setMargin(new Insets(0, 10, 0, 10));
    etcPropertyButton.addActionListener(new ActionListener() {
        private ParameterSetWindow ps = null;

        public void actionPerformed(ActionEvent e) {
            // ??????????
            if (!isSubWindow) {
                ps = new ParameterSetWindow(getParentFrame());
            } else {
                ps.requestFocus();
            }
        }
    });

    JPanel optionPanel = new JPanel();
    optionPanel.setLayout(new BoxLayout(optionPanel, BoxLayout.Y_AXIS));
    optionPanel.add(dispModePanel);
    optionPanel.add(paramPanel);

    // PackageView?????
    pkgView = new PackageViewPanel();
    pkgView.initAllRecInfo();

    queryTabPane.addTab("DB", parentPanel2);
    queryTabPane.setToolTipTextAt(TAB_ORDER_DB, "Query from DB.");
    queryTabPane.addTab("File", queryFilePane);
    queryTabPane.setToolTipTextAt(TAB_ORDER_FILE, "Query from user file.");
    queryTabPane.setSelectedIndex(TAB_ORDER_DB);
    queryTabPane.setFocusable(false);
    queryTabPane.addChangeListener(new ChangeListener() {
        public void stateChanged(ChangeEvent e) {

            // ?
            queryPlot.clear();
            compPlot.clear();
            resultPlot.clear();
            queryPlot.setPeaks(null, 0);
            compPlot.setPeaks(null, 1);
            resultPlot.setPeaks(null, 0);

            // PackageView?
            pkgView.initAllRecInfo();

            // DB Hit?
            if (resultTabPane.getTabCount() > 0) {
                resultTabPane.setSelectedIndex(0);
            }
            DefaultTableModel dataModel = (DefaultTableModel) resultSorter.getTableModel();
            dataModel.setRowCount(0);
            hitLabel.setText(" ");

            // DB?User File??????
            queryTabPane.update(queryTabPane.getGraphics());
            if (queryTabPane.getSelectedIndex() == TAB_ORDER_DB) {
                parentPanel2.update(parentPanel2.getGraphics());
                updateSelectQueryTable(queryDbTable);
            } else if (queryTabPane.getSelectedIndex() == TAB_ORDER_FILE) {
                queryFilePane.update(queryFilePane.getGraphics());
                updateSelectQueryTable(queryFileTable);
            }
        }
    });

    //       
    JPanel queryPanel = new JPanel();
    queryPanel.setLayout(new BorderLayout());
    queryPanel.add(queryTabPane, BorderLayout.CENTER);
    queryPanel.add(optionPanel, BorderLayout.SOUTH);
    queryPanel.setMinimumSize(new Dimension(0, 170));

    JPanel jtp2Panel = new JPanel();
    jtp2Panel.setLayout(new BorderLayout());
    jtp2Panel.add(dbPanel, BorderLayout.CENTER);
    jtp2Panel.add(hitLabel, BorderLayout.SOUTH);
    jtp2Panel.setMinimumSize(new Dimension(0, 70));
    Color colorGreen = new Color(0, 128, 0);
    hitLabel.setForeground(colorGreen);

    resultTabPane.addTab("Result", jtp2Panel);
    resultTabPane.setToolTipTextAt(TAB_RESULT_DB, "Result of DB hit.");
    resultTabPane.setFocusable(false);

    queryPlot.setMinimumSize(new Dimension(0, 100));
    compPlot.setMinimumSize(new Dimension(0, 120));
    resultPlot.setMinimumSize(new Dimension(0, 100));
    int height = initAppletHight / 3;
    JSplitPane jsp_cmp2db = new JSplitPane(JSplitPane.VERTICAL_SPLIT, compPlot, resultPlot);
    JSplitPane jsp_qry2cmp = new JSplitPane(JSplitPane.VERTICAL_SPLIT, queryPlot, jsp_cmp2db);
    jsp_cmp2db.setDividerLocation(height);
    jsp_qry2cmp.setDividerLocation(height - 25);
    jsp_qry2cmp.setMinimumSize(new Dimension(190, 0));

    viewTabPane.addTab("Compare View", jsp_qry2cmp);
    viewTabPane.addTab("Package View", pkgView);
    viewTabPane.setToolTipTextAt(TAB_VIEW_COMPARE, "Comparison of query and result spectrum.");
    viewTabPane.setToolTipTextAt(TAB_VIEW_PACKAGE, "Package comparison of query and result spectrum.");
    viewTabPane.setSelectedIndex(TAB_VIEW_COMPARE);
    viewTabPane.setFocusable(false);

    JSplitPane jsp = new JSplitPane(JSplitPane.VERTICAL_SPLIT, queryPanel, resultTabPane);
    jsp.setDividerLocation(310);
    jsp.setMinimumSize(new Dimension(180, 0));
    jsp.setOneTouchExpandable(true);

    JSplitPane jsp2 = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, jsp, viewTabPane);
    int divideSize = (int) (initAppletWidth * 0.4);
    divideSize = (divideSize >= 180) ? divideSize : 180;
    jsp2.setDividerLocation(divideSize);
    jsp2.setOneTouchExpandable(true);

    mainPanel.add(jsp2, BorderLayout.CENTER);
    add(mainPanel);

    queryPlot.setSearchPage(this);
    compPlot.setSearchPage(this);
    resultPlot.setSearchPage(this);

    setJMenuBar(MenuBarGenerator.generateMenuBar(this));
}

From source file:org.geworkbench.engine.ccm.ComponentConfigurationManagerWindow.java

/**
 * Set up the GUI/*w ww. j  a v  a2  s  .co  m*/
 * 
 * @param void
 * @return void
 */
private void initComponents() {
    frame = new JFrame("geWorkbench - Component Configuration Manager");

    topPanel = new JPanel();
    displayLabel = new JLabel();
    String[] displayChoices = { DISPLAY_FILTER_ALL, DISPLAY_ONLY_LOADED, DISPLAY_ONLY_UNLOADED };
    displayComboBox = new JComboBox(displayChoices);
    showByTypeLabel = new JLabel();
    String[] showByTypeChoices = new String[PluginComponent.categoryList.size() + 2];
    showByTypeChoices[0] = SHOW_BY_TYPE_ALL;
    int index = 1;
    for (String s : PluginComponent.categoryList) {
        showByTypeChoices[index] = s.substring(0, 1).toUpperCase() + s.substring(1).toLowerCase();
        index++;
    }
    ;
    showByTypeChoices[index] = SHOW_BY_TYPE_OTHERS;
    Arrays.sort(showByTypeChoices);
    showByTypeComboBox = new JComboBox(showByTypeChoices);
    showByTypeComboBox.setMaximumRowCount(showByTypeChoices.length);
    keywordSearchLabel = new JLabel("Keyword search:");
    keywordSearchField = new JTextField("Enter Text");
    splitPane = new JSplitPane();
    scrollPaneForTextPane = new JScrollPane();
    textPane = new JTextPane();
    bottompanel = new JPanel();
    CellConstraints cc = new CellConstraints();

    frame.addWindowListener(new WindowAdapter() {
        @Override
        public void windowClosing(WindowEvent e) {
            ccmWindow = null;
        }
    });

    viewLicenseButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            viewLicense_actionPerformed(e);
        }
    });

    applyButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            applyCcmSelections_actionPerformed(e);
        }
    });
    resetButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            resetCcmSelections_actionPerformed(e);
        }

    });
    closeButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            closeCcmSelections_actionPerformed(e);
        }

    });

    //======== frame ========
    {
        Container frameContentPane = frame.getContentPane();
        frameContentPane.setLayout(new BorderLayout());

        //======== outerPanel ========
        {

            frameContentPane.addPropertyChangeListener(new java.beans.PropertyChangeListener() {
                public void propertyChange(java.beans.PropertyChangeEvent e) {
                    if ("border".equals(e.getPropertyName()))
                        throw new RuntimeException();
                }
            });

            //======== topPanel ========
            {
                FormLayout topPanelLayout = new FormLayout(
                        " 32dlu, default,  4dlu, default,  32dlu, default,  4dlu, default, 32dlu, default,  4dlu, 64dlu, 32dlu",
                        "center:25dlu");
                topPanel.setLayout(topPanelLayout);

                //---- displayLabel ----
                displayLabel.setText("Display:");
                topPanel.add(displayLabel, cc.xy(2, 1));
                //======== scrollPaneForTopList1 ========
                {
                    //---- displayComboBox ----
                    ActionListener actionListener = new ActionListener() {
                        public void actionPerformed(ActionEvent actionEvent) {
                            ItemSelectable is = (ItemSelectable) actionEvent.getSource();
                            Object[] selections = is.getSelectedObjects();
                            String selection = (String) selections[0];
                            ccmTableModel.setLoadedFilterValue(selection);
                            sorter.setRowFilter(combinedFilter);
                            ccmTableModel.fireTableDataChanged();
                        }
                    };

                    displayComboBox.addActionListener(actionListener);
                }
                topPanel.add(displayComboBox, cc.xy(4, 1));

                //---- showByTypeLabel ----
                showByTypeLabel.setText("Show by type:");
                topPanel.add(showByTypeLabel, cc.xy(6, 1));
                //======== scrollPaneForTopList2 ========
                {
                    //---- showByTypeComboBox ----
                    ActionListener actionListener2 = new ActionListener() {
                        public void actionPerformed(ActionEvent actionEvent) {
                            ItemSelectable is = (ItemSelectable) actionEvent.getSource();
                            Object[] selections = is.getSelectedObjects();
                            String selection = (String) selections[0];
                            ccmTableModel.setTypeFilterValue(selection);
                            sorter.setRowFilter(combinedFilter);
                            ccmTableModel.fireTableDataChanged();
                        }
                    };

                    showByTypeComboBox.addActionListener(actionListener2);
                }
                topPanel.add(showByTypeComboBox, cc.xy(8, 1));

                //---- topLabel3 ----               
                topPanel.add(keywordSearchLabel, cc.xy(10, 1));

                //======== scrollPaneForTopList3 ========
                {
                    // ---- keywordSearchField ----
                    KeyListener actionListener3 = new KeyListener() {

                        public void keyPressed(KeyEvent e) {
                        }

                        public void keyReleased(KeyEvent e) {
                            String text = keywordSearchField.getText();
                            ccmTableModel.setKeywordFilterValue(text);
                            sorter.setRowFilter(combinedFilter);
                            ccmTableModel.fireTableDataChanged();
                        }

                        public void keyTyped(KeyEvent e) {
                        }
                    };

                    keywordSearchField.setText("Enter Text");
                    keywordSearchField.addKeyListener(actionListener3);
                }
                topPanel.add(keywordSearchField, cc.xy(12, 1));
            } // Top Panel
            frameContentPane.add(topPanel, BorderLayout.NORTH);

            //======== splitPane ========
            {
                splitPane.setOrientation(JSplitPane.VERTICAL_SPLIT);
                splitPane.setResizeWeight(0.5);

                //======== scrollPaneForTable ========
                {
                    //---- table ----
                    ccmTableModel = new CCMTableModel(manager);
                    setOriginalChoices();
                    table = new JTable(ccmTableModel);
                    sorter = new TableRowSorter<CCMTableModel>(ccmTableModel);
                    table.setRowSorter(sorter);

                    table.setDefaultRenderer(Object.class, new CellRenderer());
                    table.setDefaultRenderer(CCMTableModel.ImageLink.class, new ImageLinkRenderer());
                    table.setDefaultRenderer(CCMTableModel.HyperLink.class, new HyperLinkRenderer());
                    table.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS);

                    ListSelectionModel cellSM = table.getSelectionModel();
                    cellSM.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
                    cellSM.addListSelectionListener(new ListSelectionListener() {
                        public void valueChanged(ListSelectionEvent e) {
                            boolean adjusting = e.getValueIsAdjusting();
                            if (adjusting) {
                                return;
                            }
                            int selectedRow = table.getSelectedRow();
                            ListSelectionModel lsm = (ListSelectionModel) e.getSource();
                            if (lsm.isSelectionEmpty()) {
                                textPane.setText(" ");
                            } else {
                                String description = (String) ccmTableModel.getValueAt(
                                        table.convertRowIndexToModel(selectedRow),
                                        CCMTableModel.DESCRIPTION_INDEX);
                                textPane.setText(description);

                                if (textPane.getCaretPosition() > 1) {
                                    textPane.setCaretPosition(1);
                                }
                            }
                        }
                    });

                    table.addMouseListener(new MouseAdapter() {

                        @Override
                        public void mouseClicked(java.awt.event.MouseEvent event) {
                            launchBrowser();
                        }
                    });

                    TableColumn column = table.getColumnModel().getColumn(CCMTableModel.SELECTION_INDEX);
                    column.setMaxWidth(50);
                    column = table.getColumnModel().getColumn(CCMTableModel.VERSION_INDEX);
                    column.setMaxWidth(60);
                    column = table.getColumnModel().getColumn(CCMTableModel.TUTORIAL_URL_INDEX);
                    column.setMaxWidth(70);
                    column = table.getColumnModel().getColumn(CCMTableModel.TOOL_URL_INDEX);
                    column.setMaxWidth(70);

                    scrollPaneForTable = new JScrollPane(table);
                }
                splitPane.setTopComponent(scrollPaneForTable);

                //======== scrollPaneForTextPane ========
                {
                    //---- textPane ----
                    textPane.setEditable(false);
                    scrollPaneForTextPane.setViewportView(textPane);
                }
                splitPane.setBottomComponent(scrollPaneForTextPane);
            } //======== splitPane ========.
            frameContentPane.add(splitPane, BorderLayout.CENTER);

            //======== bottompanel ========
            {
                bottompanel.setLayout(new FormLayout("20dlu," + "default,  4dlu, " + // view License
                        "default,200dlu, " + // Apply
                        "default,  4dlu, " + // Reset
                        "default,  4dlu, " + // Cancel
                        "default " // Close
                        , "center:25dlu"));

                viewLicenseButton.setText("View License");
                bottompanel.add(viewLicenseButton, cc.xy(2, 1));

                //---- applyButton ----
                applyButton.setText("Apply");
                bottompanel.add(applyButton, cc.xy(6, 1));

                //---- resetButton ----
                resetButton.setText("Reset");
                bottompanel.add(resetButton, cc.xy(8, 1));

                //---- closeButton ----
                closeButton.setText("Close");
                bottompanel.add(closeButton, cc.xy(10, 1));

            } //======== bottompanel ========.
            frameContentPane.add(bottompanel, BorderLayout.SOUTH);
        } //======== outerPanel ========
        frame.pack();
        frame.setLocationRelativeTo(frame.getOwner());
    } // ============ frame ============

    topPanel.setVisible(true);
    splitPane.setVisible(true);
    scrollPaneForTable.setVisible(true);
    table.setVisible(true);
    scrollPaneForTextPane.setVisible(true);
    textPane.setVisible(true);
    bottompanel.setVisible(true);
    sorter.setRowFilter(combinedFilter);
    frame.setVisible(true);
    splitPane.setDividerLocation(.7d);
}

From source file:org.geworkbench.engine.ccm.ComponentConfigurationManagerWindow2.java

/**
 * Set up the GUI//from ww w.j a v a  2 s. c  o m
 * 
 * @param void
 * @return void
 */
private void initComponents() {
    frame = new JFrame("geWorkbench - Component Configuration Manager");

    topPanel = new JPanel();
    displayLabel = new JLabel();
    String[] displayChoices = { DISPLAY_FILTER_ALL, DISPLAY_ONLY_LOADED, DISPLAY_ONLY_UNLOADED };
    displayComboBox = new JComboBox(displayChoices);
    showByTypeLabel = new JLabel();
    String[] showByTypeChoices = new String[PluginComponent.categoryList.size() + 2];
    showByTypeChoices[0] = SHOW_BY_TYPE_ALL;
    int index = 1;
    for (String s : PluginComponent.categoryList) {
        showByTypeChoices[index] = s.substring(0, 1).toUpperCase() + s.substring(1).toLowerCase();
        index++;
    }
    ;
    showByTypeChoices[index] = SHOW_BY_TYPE_OTHERS;
    Arrays.sort(showByTypeChoices);
    showByTypeComboBox = new JComboBox(showByTypeChoices);
    showByTypeComboBox.setMaximumRowCount(showByTypeChoices.length);
    keywordSearchLabel = new JLabel("Keyword search:");
    keywordSearchField = new JTextField("Enter Text");
    splitPane = new JSplitPane();
    scrollPaneForTextPane = new JScrollPane();
    textPane = new JTextPane();
    bottompanel = new JPanel();
    CellConstraints cc = new CellConstraints();

    frame.addWindowListener(new WindowAdapter() {
        @Override
        public void windowClosing(WindowEvent e) {
            ccmWindow = null;
        }
    });

    viewLicenseButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            viewLicense_actionPerformed(e);
        }
    });

    applyButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            applyCcmSelections_actionPerformed(e);
        }
    });
    resetButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            resetCcmSelections_actionPerformed(e);
        }

    });
    closeButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            closeCcmSelections_actionPerformed(e);
        }

    });
    componentUpdateButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            componentRemoteUpdate_actionPerformed(e);
        }

    });

    //======== frame ========
    {
        Container frameContentPane = frame.getContentPane();
        frameContentPane.setLayout(new BorderLayout());

        //======== outerPanel ========
        {

            frameContentPane.addPropertyChangeListener(new java.beans.PropertyChangeListener() {
                public void propertyChange(java.beans.PropertyChangeEvent e) {
                    if ("border".equals(e.getPropertyName()))
                        throw new RuntimeException();
                }
            });

            //======== topPanel ========
            {
                FormLayout topPanelLayout = new FormLayout(
                        " 32dlu, default,  4dlu, default,  32dlu, default,  4dlu, default, 32dlu, default,  4dlu, 64dlu, 32dlu",
                        "center:25dlu");
                topPanel.setLayout(topPanelLayout);

                //---- displayLabel ----
                displayLabel.setText("Display:");
                topPanel.add(displayLabel, cc.xy(2, 1));
                //======== scrollPaneForTopList1 ========
                {
                    //---- displayComboBox ----
                    ActionListener actionListener = new ActionListener() {
                        public void actionPerformed(ActionEvent actionEvent) {
                            ItemSelectable is = (ItemSelectable) actionEvent.getSource();
                            Object[] selections = is.getSelectedObjects();
                            String selection = (String) selections[0];
                            ccmTableModel.setLoadedFilterValue(selection);
                            sorter.setRowFilter(combinedFilter);
                            ccmTableModel.fireTableDataChanged();
                        }
                    };

                    displayComboBox.addActionListener(actionListener);
                }
                topPanel.add(displayComboBox, cc.xy(4, 1));

                //---- showByTypeLabel ----
                showByTypeLabel.setText("Show by type:");
                topPanel.add(showByTypeLabel, cc.xy(6, 1));
                //======== scrollPaneForTopList2 ========
                {
                    //---- showByTypeComboBox ----
                    ActionListener actionListener2 = new ActionListener() {
                        public void actionPerformed(ActionEvent actionEvent) {
                            ItemSelectable is = (ItemSelectable) actionEvent.getSource();
                            Object[] selections = is.getSelectedObjects();
                            String selection = (String) selections[0];
                            ccmTableModel.setTypeFilterValue(selection);
                            sorter.setRowFilter(combinedFilter);
                            ccmTableModel.fireTableDataChanged();
                        }
                    };

                    showByTypeComboBox.addActionListener(actionListener2);
                }
                topPanel.add(showByTypeComboBox, cc.xy(8, 1));

                //---- topLabel3 ----               
                topPanel.add(keywordSearchLabel, cc.xy(10, 1));

                //======== scrollPaneForTopList3 ========
                {
                    // ---- keywordSearchField ----
                    KeyListener actionListener3 = new KeyListener() {

                        public void keyPressed(KeyEvent e) {
                        }

                        public void keyReleased(KeyEvent e) {
                            String text = keywordSearchField.getText();
                            ccmTableModel.setKeywordFilterValue(text);
                            sorter.setRowFilter(combinedFilter);
                            ccmTableModel.fireTableDataChanged();
                        }

                        public void keyTyped(KeyEvent e) {
                        }
                    };

                    keywordSearchField.setText("Enter Text");
                    keywordSearchField.addKeyListener(actionListener3);
                }
                topPanel.add(keywordSearchField, cc.xy(12, 1));
            } // Top Panel
            frameContentPane.add(topPanel, BorderLayout.NORTH);

            //======== splitPane ========
            {
                splitPane.setOrientation(JSplitPane.VERTICAL_SPLIT);
                splitPane.setResizeWeight(0.5);

                //======== scrollPaneForTable ========
                {
                    //---- table ----
                    ccmTableModel = new CCMTableModel2(manager.componentConfigurationManager);
                    setOriginalChoices();
                    table = new JTable(ccmTableModel);
                    sorter = new TableRowSorter<CCMTableModel2>(ccmTableModel);
                    table.setRowSorter(sorter);

                    table.setDefaultRenderer(Object.class, new CellRenderer());
                    table.setDefaultRenderer(CCMTableModel2.ImageLink.class, new ImageLinkRenderer());
                    table.setDefaultRenderer(CCMTableModel2.HyperLink.class, new HyperLinkRenderer());
                    table.setDefaultRenderer(CCMTableModel2.DownloadLink.class, new DownloadLinkRenderer());
                    table.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS);

                    ListSelectionModel cellSM = table.getSelectionModel();
                    cellSM.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
                    cellSM.addListSelectionListener(new ListSelectionListener() {
                        public void valueChanged(ListSelectionEvent e) {
                            boolean adjusting = e.getValueIsAdjusting();
                            if (adjusting) {
                                return;
                            }
                            int[] selectedRow = table.getSelectedRows();
                            ListSelectionModel lsm = (ListSelectionModel) e.getSource();
                            if (lsm.isSelectionEmpty()) {
                                textPane.setText(" ");
                            } else {
                                String description = (String) ccmTableModel.getValueAt(
                                        table.convertRowIndexToModel(selectedRow[0]),
                                        CCMTableModel2.DESCRIPTION_INDEX);
                                textPane.setText(description);

                                if (textPane.getCaretPosition() > 1) {
                                    textPane.setCaretPosition(1);
                                }
                            }

                            if (table.getSelectedRow() >= 0) {
                                int modelColumn = table.convertColumnIndexToModel(table.getSelectedColumn());
                                if (modelColumn == CCMTableModel2.AVAILABLE_UPDATE_INDEX)
                                    installRemoteComponent();
                                else
                                    launchBrowser();
                            }
                        }
                    });

                    TableColumn column = table.getColumnModel().getColumn(CCMTableModel2.SELECTION_INDEX);
                    column.setMaxWidth(50);
                    column = table.getColumnModel().getColumn(CCMTableModel2.VERSION_INDEX);
                    column.setMaxWidth(60);
                    column = table.getColumnModel().getColumn(CCMTableModel2.AVAILABLE_UPDATE_INDEX);
                    column.setMaxWidth(60);
                    column = table.getColumnModel().getColumn(CCMTableModel2.TUTORIAL_URL_INDEX_2);
                    column.setMaxWidth(70);
                    column = table.getColumnModel().getColumn(CCMTableModel2.TOOL_URL_INDEX_2);
                    column.setMaxWidth(70);

                    scrollPaneForTable = new JScrollPane(table);
                }
                splitPane.setTopComponent(scrollPaneForTable);

                //======== scrollPaneForTextPane ========
                {
                    //---- textPane ----
                    textPane.setEditable(false);
                    scrollPaneForTextPane.setViewportView(textPane);
                }
                splitPane.setBottomComponent(scrollPaneForTextPane);
            } //======== splitPane ========.
            frameContentPane.add(splitPane, BorderLayout.CENTER);

            //======== bottompanel ========
            {
                bottompanel.setLayout(new FormLayout("20dlu," + "default,  4dlu, " + // view License
                        "default,100dlu, " + // Component Update
                        "default,  4dlu, " + // Apply
                        "default,  4dlu, " + // Reset
                        "default,  4dlu, " + // Cancel
                        "default " // Close
                        , "center:25dlu"));

                viewLicenseButton.setText("View License");
                bottompanel.add(viewLicenseButton, cc.xy(2, 1));

                //---- componentUpdateButton ----
                bottompanel.add(componentUpdateButton, cc.xy(6, 1));

                //---- applyButton ----
                applyButton.setText("Apply");
                bottompanel.add(applyButton, cc.xy(8, 1));

                //---- resetButton ----
                resetButton.setText("Reset");
                bottompanel.add(resetButton, cc.xy(10, 1));

                //---- closeButton ----
                closeButton.setText("Close");
                bottompanel.add(closeButton, cc.xy(12, 1));

            } //======== bottompanel ========.
            frameContentPane.add(bottompanel, BorderLayout.SOUTH);
        } //======== outerPanel ========
        frame.pack();
        frame.setLocationRelativeTo(frame.getOwner());
    } // ============ frame ============

    topPanel.setVisible(true);
    splitPane.setVisible(true);
    scrollPaneForTable.setVisible(true);
    table.setVisible(true);
    scrollPaneForTextPane.setVisible(true);
    textPane.setVisible(true);
    bottompanel.setVisible(true);
    sorter.setRowFilter(combinedFilter);
    frame.setVisible(true);
    splitPane.setDividerLocation(.7d);
}

From source file:pcgen.gui2.tabs.DomainInfoTab.java

private void initComponents() {
    setOrientation(VERTICAL_SPLIT);//from  w ww  .j a  va  2s  .  c  o  m

    JPanel panel = new JPanel(new BorderLayout());
    FilterBar bar = new FilterBar();
    bar.addDisplayableFilter(new SearchFilterPanel());
    deityTable.setDisplayableFilter(bar);
    panel.add(bar, BorderLayout.NORTH);

    deityTable.setSortingPriority(Collections.singletonList(new SortingPriority(0, SortMode.ASCENDING)));
    deityTable.sortModel();
    ListSelectionModel selectionModel = deityTable.getSelectionModel();
    selectionModel.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    panel.add(new JScrollPane(deityTable), BorderLayout.CENTER);

    Box box = Box.createHorizontalBox();
    box.add(Box.createHorizontalGlue());
    box.add(new JLabel("Deity:"));
    box.add(Box.createHorizontalStrut(5));
    box.add(selectedDeity);
    box.add(Box.createHorizontalStrut(5));
    box.add(selectDeity);
    box.add(Box.createHorizontalGlue());
    panel.add(box, BorderLayout.SOUTH);

    FlippingSplitPane splitPane = new FlippingSplitPane();
    splitPane.setLeftComponent(panel);

    panel = new JPanel(new BorderLayout());
    bar = new FilterBar();
    bar.addDisplayableFilter(new SearchFilterPanel());
    domainFilter = bar;
    panel.add(bar, BorderLayout.NORTH);
    selectionModel = domainTable.getSelectionModel();
    selectionModel.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    JScrollPane scrollPane = TableUtils.createCheckBoxSelectionPane(domainTable, domainRowHeaderTable);
    panel.add(scrollPane, BorderLayout.CENTER);

    box = Box.createHorizontalBox();
    box.add(Box.createHorizontalGlue());
    box.add(new JLabel("Domains Remaining to be Selected:"));
    box.add(Box.createHorizontalStrut(5));
    box.add(selectedDomain);
    box.add(Box.createHorizontalGlue());

    panel.add(box, BorderLayout.SOUTH);

    splitPane.setRightComponent(panel);
    setTopComponent(splitPane);
    splitPane = new FlippingSplitPane();
    splitPane.setLeftComponent(deityInfo);
    splitPane.setRightComponent(domainInfo);
    setBottomComponent(splitPane);
    setResizeWeight(.65);
}