Search in sources :

Example 36 with ChangeListener

use of javax.swing.event.ChangeListener in project zaproxy by zaproxy.

the class OptionsViewPanel method getFontSize.

private ZapNumberSpinner getFontSize() {
    if (fontSize == null) {
        fontSize = new ZapNumberSpinner(-1, 8, 100);
        if (!FontUtils.canChangeSize()) {
            fontSize.setEnabled(false);
        }
        fontSize.addChangeListener(new ChangeListener() {

            @Override
            public void stateChanged(ChangeEvent e) {
                // Show what the default font will look like
                setExampleFont();
            }
        });
    }
    return fontSize;
}
Also used : ChangeEvent(javax.swing.event.ChangeEvent) ZapNumberSpinner(org.zaproxy.zap.utils.ZapNumberSpinner) ChangeListener(javax.swing.event.ChangeListener)

Example 37 with ChangeListener

use of javax.swing.event.ChangeListener in project frostwire by frostwire.

the class MPlayerOverlayControls method setupUI.

private void setupUI() {
    Container panel = getContentPane();
    ImageIcon backgroundImage = GUIMediator.getThemeImage(OSUtils.isLinux() ? "fc_background_linux" : "fc_background");
    Dimension winSize = new Dimension(backgroundImage.getIconWidth(), backgroundImage.getIconHeight());
    setPreferredSize(winSize);
    setSize(winSize);
    setUndecorated(true);
    try {
        setBackground(new Color(0, 0, 0, 0));
    } catch (UnsupportedOperationException e) {
        // platform does not support per-pixel translucency
        setBackground(new Color(0, 0, 0));
    }
    if (OSUtils.isMacOSX()) {
        GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
        GraphicsDevice gd = ge.getDefaultScreenDevice();
        final boolean perPixelTransparentSupported = gd.isWindowTranslucencySupported(WindowTranslucency.PERPIXEL_TRANSPARENT);
        if (perPixelTransparentSupported) {
            addComponentListener(new ComponentAdapter() {

                @Override
                public void componentResized(ComponentEvent e) {
                    setShape(new RoundRectangle2D.Double(0, 0, getWidth(), getHeight(), 15, 15));
                }
            });
        }
        setOpacity(0.90f);
    }
    if (OSUtils.isLinux()) {
        setType(Type.POPUP);
    }
    // osx specific (won't harm windows/linux)
    getRootPane().putClientProperty("apple.awt.draggableWindowBackground", Boolean.FALSE);
    panel.setLayout(null);
    panel.setBounds(0, 0, winSize.width, winSize.height);
    // background image
    // ------------------
    JLabel backgroundJLabel = new JLabel(backgroundImage);
    backgroundJLabel.setOpaque(false);
    backgroundJLabel.setSize(backgroundImage.getIconWidth(), backgroundImage.getIconHeight());
    // play button
    // ------------
    Point playButtonPos = new Point(236, 13);
    playButton = MPlayerOverlayControls.createMPlayerButton("fc_play", playButtonPos);
    playButton.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            MPlayerOverlayControls.this.onPlayPressed();
        }
    });
    OverlayControlsMouseAdapter overlayControlsMouseAdapter = new OverlayControlsMouseAdapter();
    playButton.addMouseListener(overlayControlsMouseAdapter);
    panel.add(playButton);
    // pause button
    // --------------
    Point pauseButtonPos = new Point(236, 13);
    pauseButton = MPlayerOverlayControls.createMPlayerButton("fc_pause", pauseButtonPos);
    pauseButton.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            MPlayerOverlayControls.this.onPausePressed();
        }
    });
    pauseButton.addMouseListener(overlayControlsMouseAdapter);
    pauseButton.addMouseMotionListener(overlayControlsMouseAdapter);
    panel.add(pauseButton);
    // fast forward button
    // --------------------
    Point fastForwardButtonPos = new Point(306, 18);
    JButton fastForwardButton;
    fastForwardButton = MPlayerOverlayControls.createMPlayerButton("fc_next", fastForwardButtonPos);
    fastForwardButton.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            MPlayerOverlayControls.this.onFastForwardPressed();
        }
    });
    fastForwardButton.addMouseListener(overlayControlsMouseAdapter);
    fastForwardButton.addMouseMotionListener(overlayControlsMouseAdapter);
    panel.add(fastForwardButton);
    // rewind button
    // --------------
    Point rewindButtonPos = new Point(182, 18);
    JButton rewindButton;
    rewindButton = MPlayerOverlayControls.createMPlayerButton("fc_previous", rewindButtonPos);
    rewindButton.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent arg0) {
            MPlayerOverlayControls.this.onRewindPressed();
        }
    });
    rewindButton.addMouseListener(overlayControlsMouseAdapter);
    rewindButton.addMouseMotionListener(overlayControlsMouseAdapter);
    panel.add(rewindButton);
    // full screen exit button
    // ------------------------
    Point fullscreenButtonPos = new Point(390, 22);
    fullscreenExitButton = MPlayerOverlayControls.createMPlayerButton("fc_fullscreen_exit", fullscreenButtonPos);
    fullscreenExitButton.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent arg0) {
            MPlayerOverlayControls.this.onFullscreenExitPressed();
        }
    });
    fullscreenExitButton.addMouseListener(overlayControlsMouseAdapter);
    fullscreenExitButton.addMouseMotionListener(overlayControlsMouseAdapter);
    panel.add(fullscreenExitButton);
    // full screen enter button
    // ------------------------
    fullscreenEnterButton = MPlayerOverlayControls.createMPlayerButton("fc_fullscreen_enter", fullscreenButtonPos);
    fullscreenEnterButton.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent arg0) {
            MPlayerOverlayControls.this.onFullscreenEnterPressed();
        }
    });
    fullscreenEnterButton.addMouseListener(overlayControlsMouseAdapter);
    fullscreenEnterButton.addMouseMotionListener(overlayControlsMouseAdapter);
    panel.add(fullscreenEnterButton);
    // volume slider
    // --------------
    JPanel volumePanel = new JPanel(new BorderLayout());
    volumePanel.setBounds(20, 20, 125, 25);
    volumePanel.setOpaque(false);
    ImageIcon volMinIcon = GUIMediator.getThemeImage("fc_volume_off");
    JLabel volMinLabel = new JLabel(volMinIcon);
    volMinLabel.setOpaque(false);
    volMinLabel.setSize(volMinIcon.getIconWidth(), volMinIcon.getIconHeight());
    volumePanel.add(volMinLabel, BorderLayout.WEST);
    volumeSlider = new JSlider();
    volumeSlider.setOpaque(false);
    volumeSlider.setFocusable(false);
    volumeSlider.addChangeListener(new ChangeListener() {

        public void stateChanged(ChangeEvent e) {
            MPlayerOverlayControls.this.onVolumeChanged(((JSlider) e.getSource()).getValue());
        }
    });
    volumeSlider.addMouseListener(overlayControlsMouseAdapter);
    volumeSlider.addMouseMotionListener(overlayControlsMouseAdapter);
    volumePanel.add(volumeSlider, BorderLayout.CENTER);
    ImageIcon volMaxIcon = GUIMediator.getThemeImage("fc_volume_on");
    JLabel volMaxLabel = new JLabel(volMaxIcon);
    volMaxLabel.setSize(volMaxIcon.getIconWidth(), volMaxIcon.getIconHeight());
    volumePanel.add(volMaxLabel, BorderLayout.EAST);
    panel.add(volumePanel);
    // progress slider
    // ----------------
    progressSlider = new ProgressSlider();
    progressSlider.addProgressSliderListener(this);
    progressSlider.setLocation(20, 70);
    progressSlider.addMouseListener(overlayControlsMouseAdapter);
    progressSlider.addMouseMotionListener(overlayControlsMouseAdapter);
    panel.add(progressSlider);
    panel.add(backgroundJLabel);
}
Also used : ChangeEvent(javax.swing.event.ChangeEvent) ChangeListener(javax.swing.event.ChangeListener)

Example 38 with ChangeListener

use of javax.swing.event.ChangeListener in project frostwire by frostwire.

the class SearchOptionsPanel method createSizeFilter.

private LabeledRangeSlider createSizeFilter() {
    LabeledRangeSlider slider = new LabeledRangeSlider(I18n.tr("Size"), null, 0, 1000);
    slider.setPreferredSize(new Dimension(240, (int) slider.getPreferredSize().getHeight()));
    slider.addChangeListener(new ChangeListener() {

        public void stateChanged(ChangeEvent e) {
            sliderSize_stateChanged();
        }
    });
    return slider;
}
Also used : ChangeEvent(javax.swing.event.ChangeEvent) ChangeListener(javax.swing.event.ChangeListener)

Example 39 with ChangeListener

use of javax.swing.event.ChangeListener in project SEPA by arces-wot.

the class Dashboard method initialize.

/**
 * Initialize the contents of the frame.
 */
private void initialize() {
    namespacesDM = new DefaultTableModel(0, 0) {

        /**
         */
        private static final long serialVersionUID = 6788045463932990156L;

        @Override
        public boolean isCellEditable(int row, int column) {
            return false;
        }
    };
    namespacesDM.setColumnIdentifiers(namespacesHeader);
    propertiesDM = new DefaultTableModel(0, 0) {

        /**
         */
        private static final long serialVersionUID = -5161490469556412655L;

        @Override
        public boolean isCellEditable(int row, int column) {
            return false;
        }
    };
    propertiesDM.setColumnIdentifiers(propertiesHeader);
    frmSepaDashboard = new JFrame();
    frmSepaDashboard.setTitle(versionLabel);
    frmSepaDashboard.setBounds(100, 100, 925, 768);
    frmSepaDashboard.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    GridBagLayout gridBagLayout = new GridBagLayout();
    gridBagLayout.columnWidths = new int[] { 925, 0 };
    gridBagLayout.rowHeights = new int[] { 78, 651, 39, 0 };
    gridBagLayout.columnWeights = new double[] { 1.0, Double.MIN_VALUE };
    gridBagLayout.rowWeights = new double[] { 0.0, 1.0, 0.0, Double.MIN_VALUE };
    frmSepaDashboard.getContentPane().setLayout(gridBagLayout);
    JPanel configuration = new JPanel();
    GridBagConstraints gbc_configuration = new GridBagConstraints();
    gbc_configuration.insets = new Insets(0, 0, 5, 0);
    gbc_configuration.fill = GridBagConstraints.BOTH;
    gbc_configuration.gridx = 0;
    gbc_configuration.gridy = 0;
    frmSepaDashboard.getContentPane().add(configuration, gbc_configuration);
    configuration.setBorder(new TitledBorder(null, "Configuration", TitledBorder.LEADING, TitledBorder.TOP, null, null));
    GridBagLayout gbl_configuration = new GridBagLayout();
    gbl_configuration.columnWidths = new int[] { 46, 45, 31, 20, 0, 24, 0, 0, 0, 0, 0, 0, 37, 0 };
    gbl_configuration.rowHeights = new int[] { 9, -25, 0 };
    gbl_configuration.columnWeights = new double[] { 0.0, 1.0, 0.0, 1.0, 0.0, 1.0, 0.0, 1.0, 0.0, 1.0, 0.0, 1.0, 0.0, Double.MIN_VALUE };
    gbl_configuration.rowWeights = new double[] { 0.0, 0.0, Double.MIN_VALUE };
    configuration.setLayout(gbl_configuration);
    JLabel label1 = new JLabel("URL:");
    label1.setFont(new Font("Lucida Grande", Font.BOLD, 13));
    GridBagConstraints gbc_label1 = new GridBagConstraints();
    gbc_label1.anchor = GridBagConstraints.EAST;
    gbc_label1.insets = new Insets(0, 0, 5, 5);
    gbc_label1.gridx = 0;
    gbc_label1.gridy = 0;
    configuration.add(label1, gbc_label1);
    JButton btnLoadXmlProfile = new JButton("Load SAP profile");
    btnLoadXmlProfile.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            // String path = appProperties.getProperty("path");
            final JFileChooser fc = new JFileChooser(appProperties.getProperty("appProfile"));
            // final JFileChooser fc = new
            // JFileChooser("/Users/luca/Documents/SEPAProject/WOTDemo/tools/");
            DashboardFileFilter filter = new DashboardFileFilter("JSON SAP Profile (.jsap)", ".jsap");
            fc.setFileFilter(filter);
            int returnVal = fc.showOpenDialog(frmSepaDashboard);
            if (returnVal == JFileChooser.APPROVE_OPTION) {
                String fileName = fc.getSelectedFile().getPath();
                if (loadSAP(fileName)) {
                    FileOutputStream out = null;
                    try {
                        out = new FileOutputStream("dashboard.properties");
                    } catch (FileNotFoundException e3) {
                        logger.error(e3.getMessage());
                        return;
                    }
                    appProperties = new Properties();
                    appProperties.put("appProfile", fileName);
                    try {
                        appProperties.store(out, "Dashboard properties");
                    } catch (IOException e1) {
                        logger.error(e1.getMessage());
                    }
                    try {
                        out.close();
                    } catch (IOException e2) {
                        logger.error(e2.getMessage());
                    }
                }
            }
        }
    });
    labelUrl = new JLabel("---");
    GridBagConstraints gbc_labelUrl = new GridBagConstraints();
    gbc_labelUrl.anchor = GridBagConstraints.WEST;
    gbc_labelUrl.insets = new Insets(0, 0, 5, 5);
    gbc_labelUrl.gridx = 1;
    gbc_labelUrl.gridy = 0;
    configuration.add(labelUrl, gbc_labelUrl);
    JLabel label2 = new JLabel("http:");
    label2.setFont(new Font("Lucida Grande", Font.BOLD, 13));
    GridBagConstraints gbc_label2 = new GridBagConstraints();
    gbc_label2.insets = new Insets(0, 0, 5, 5);
    gbc_label2.gridx = 2;
    gbc_label2.gridy = 0;
    configuration.add(label2, gbc_label2);
    labelHttpPort = new JLabel("---");
    GridBagConstraints gbc_labelHttpPort = new GridBagConstraints();
    gbc_labelHttpPort.anchor = GridBagConstraints.WEST;
    gbc_labelHttpPort.insets = new Insets(0, 0, 5, 5);
    gbc_labelHttpPort.gridx = 3;
    gbc_labelHttpPort.gridy = 0;
    configuration.add(labelHttpPort, gbc_labelHttpPort);
    JLabel lblWs = new JLabel("ws:");
    lblWs.setFont(new Font("Lucida Grande", Font.BOLD, 13));
    GridBagConstraints gbc_lblWs = new GridBagConstraints();
    gbc_lblWs.insets = new Insets(0, 0, 5, 5);
    gbc_lblWs.gridx = 4;
    gbc_lblWs.gridy = 0;
    configuration.add(lblWs, gbc_lblWs);
    labelWsPort = new JLabel("---");
    GridBagConstraints gbc_labelWsPort = new GridBagConstraints();
    gbc_labelWsPort.anchor = GridBagConstraints.WEST;
    gbc_labelWsPort.insets = new Insets(0, 0, 5, 5);
    gbc_labelWsPort.gridx = 5;
    gbc_labelWsPort.gridy = 0;
    configuration.add(labelWsPort, gbc_labelWsPort);
    JLabel lblUpdate = new JLabel("update:");
    lblUpdate.setFont(new Font("Lucida Grande", Font.BOLD, 13));
    GridBagConstraints gbc_lblUpdate = new GridBagConstraints();
    gbc_lblUpdate.insets = new Insets(0, 0, 5, 5);
    gbc_lblUpdate.gridx = 6;
    gbc_lblUpdate.gridy = 0;
    configuration.add(lblUpdate, gbc_lblUpdate);
    labelUpdatePath = new JLabel("---");
    GridBagConstraints gbc_labelUpdatepath = new GridBagConstraints();
    gbc_labelUpdatepath.anchor = GridBagConstraints.WEST;
    gbc_labelUpdatepath.insets = new Insets(0, 0, 5, 5);
    gbc_labelUpdatepath.gridx = 7;
    gbc_labelUpdatepath.gridy = 0;
    configuration.add(labelUpdatePath, gbc_labelUpdatepath);
    JLabel lblQuery = new JLabel("query:");
    lblQuery.setFont(new Font("Lucida Grande", Font.BOLD, 13));
    GridBagConstraints gbc_lblQuery = new GridBagConstraints();
    gbc_lblQuery.insets = new Insets(0, 0, 5, 5);
    gbc_lblQuery.gridx = 8;
    gbc_lblQuery.gridy = 0;
    configuration.add(lblQuery, gbc_lblQuery);
    labelQueryPath = new JLabel("---");
    GridBagConstraints gbc_labelQueryPath = new GridBagConstraints();
    gbc_labelQueryPath.anchor = GridBagConstraints.WEST;
    gbc_labelQueryPath.insets = new Insets(0, 0, 5, 5);
    gbc_labelQueryPath.gridx = 9;
    gbc_labelQueryPath.gridy = 0;
    configuration.add(labelQueryPath, gbc_labelQueryPath);
    JLabel lblSubscribe = new JLabel("subscribe:");
    lblSubscribe.setFont(new Font("Lucida Grande", Font.BOLD, 13));
    GridBagConstraints gbc_lblSubscribe = new GridBagConstraints();
    gbc_lblSubscribe.insets = new Insets(0, 0, 5, 5);
    gbc_lblSubscribe.gridx = 10;
    gbc_lblSubscribe.gridy = 0;
    configuration.add(lblSubscribe, gbc_lblSubscribe);
    labelSubscribePath = new JLabel("---");
    GridBagConstraints gbc_labelSubscribePath = new GridBagConstraints();
    gbc_labelSubscribePath.anchor = GridBagConstraints.WEST;
    gbc_labelSubscribePath.insets = new Insets(0, 0, 5, 5);
    gbc_labelSubscribePath.gridx = 11;
    gbc_labelSubscribePath.gridy = 0;
    configuration.add(labelSubscribePath, gbc_labelSubscribePath);
    GridBagConstraints gbc_btnLoadXmlProfile = new GridBagConstraints();
    gbc_btnLoadXmlProfile.insets = new Insets(0, 0, 5, 0);
    gbc_btnLoadXmlProfile.anchor = GridBagConstraints.NORTHEAST;
    gbc_btnLoadXmlProfile.gridx = 12;
    gbc_btnLoadXmlProfile.gridy = 0;
    configuration.add(btnLoadXmlProfile, gbc_btnLoadXmlProfile);
    JLabel label3 = new JLabel("https:");
    label3.setFont(new Font("Lucida Grande", Font.BOLD, 13));
    GridBagConstraints gbc_label3 = new GridBagConstraints();
    gbc_label3.insets = new Insets(0, 0, 0, 5);
    gbc_label3.gridx = 2;
    gbc_label3.gridy = 1;
    configuration.add(label3, gbc_label3);
    labelHttpsPort = new JLabel("---");
    GridBagConstraints gbc_labelHttpsPort = new GridBagConstraints();
    gbc_labelHttpsPort.anchor = GridBagConstraints.WEST;
    gbc_labelHttpsPort.insets = new Insets(0, 0, 0, 5);
    gbc_labelHttpsPort.gridx = 3;
    gbc_labelHttpsPort.gridy = 1;
    configuration.add(labelHttpsPort, gbc_labelHttpsPort);
    JLabel lblWss = new JLabel("wss:");
    lblWss.setFont(new Font("Lucida Grande", Font.BOLD, 13));
    GridBagConstraints gbc_lblWss = new GridBagConstraints();
    gbc_lblWss.insets = new Insets(0, 0, 0, 5);
    gbc_lblWss.gridx = 4;
    gbc_lblWss.gridy = 1;
    configuration.add(lblWss, gbc_lblWss);
    labelWssPort = new JLabel("---");
    GridBagConstraints gbc_labelWssPort = new GridBagConstraints();
    gbc_labelWssPort.anchor = GridBagConstraints.WEST;
    gbc_labelWssPort.insets = new Insets(0, 0, 0, 5);
    gbc_labelWssPort.gridx = 5;
    gbc_labelWssPort.gridy = 1;
    configuration.add(labelWssPort, gbc_labelWssPort);
    JLabel lblNewLabel = new JLabel("secure:");
    lblNewLabel.setFont(new Font("Lucida Grande", Font.BOLD, 13));
    GridBagConstraints gbc_lblNewLabel = new GridBagConstraints();
    gbc_lblNewLabel.insets = new Insets(0, 0, 0, 5);
    gbc_lblNewLabel.gridx = 6;
    gbc_lblNewLabel.gridy = 1;
    configuration.add(lblNewLabel, gbc_lblNewLabel);
    labelSecurePath = new JLabel("---");
    GridBagConstraints gbc_labelSecurePath = new GridBagConstraints();
    gbc_labelSecurePath.anchor = GridBagConstraints.WEST;
    gbc_labelSecurePath.insets = new Insets(0, 0, 0, 5);
    gbc_labelSecurePath.gridx = 7;
    gbc_labelSecurePath.gridy = 1;
    configuration.add(labelSecurePath, gbc_labelSecurePath);
    JTabbedPane tabbedPane = new JTabbedPane(JTabbedPane.TOP);
    GridBagConstraints gbc_tabbedPane = new GridBagConstraints();
    gbc_tabbedPane.insets = new Insets(0, 0, 5, 0);
    gbc_tabbedPane.fill = GridBagConstraints.BOTH;
    gbc_tabbedPane.gridx = 0;
    gbc_tabbedPane.gridy = 1;
    frmSepaDashboard.getContentPane().add(tabbedPane, gbc_tabbedPane);
    JPanel primitives = new JPanel();
    tabbedPane.addTab("Primitives", null, primitives, null);
    primitives.setBorder(new TitledBorder(null, "Primitives", TitledBorder.LEADING, TitledBorder.TOP, null, null));
    GridBagLayout gbl_primitives = new GridBagLayout();
    gbl_primitives.columnWidths = new int[] { 684, 0, 0 };
    gbl_primitives.rowHeights = new int[] { 114, 115, 0, 0, 0 };
    gbl_primitives.columnWeights = new double[] { 1.0, 1.0, Double.MIN_VALUE };
    gbl_primitives.rowWeights = new double[] { 0.0, 0.0, 0.0, 1.0, Double.MIN_VALUE };
    primitives.setLayout(gbl_primitives);
    JSplitPane splitPanel_Update = new JSplitPane();
    splitPanel_Update.setResizeWeight(0.5);
    GridBagConstraints gbc_splitPanel_Update = new GridBagConstraints();
    gbc_splitPanel_Update.insets = new Insets(0, 0, 5, 5);
    gbc_splitPanel_Update.fill = GridBagConstraints.BOTH;
    gbc_splitPanel_Update.gridx = 0;
    gbc_splitPanel_Update.gridy = 0;
    primitives.add(splitPanel_Update, gbc_splitPanel_Update);
    JPanel panel_4 = new JPanel();
    splitPanel_Update.setLeftComponent(panel_4);
    GridBagLayout gbl_panel_4 = new GridBagLayout();
    gbl_panel_4.columnWidths = new int[] { 66, 0 };
    gbl_panel_4.rowHeights = new int[] { 17, 75, 0 };
    gbl_panel_4.columnWeights = new double[] { 1.0, Double.MIN_VALUE };
    gbl_panel_4.rowWeights = new double[] { 0.0, 1.0, Double.MIN_VALUE };
    panel_4.setLayout(gbl_panel_4);
    JLabel lblUpdates = new JLabel("UPDATEs");
    GridBagConstraints gbc_lblUpdates = new GridBagConstraints();
    gbc_lblUpdates.anchor = GridBagConstraints.NORTH;
    gbc_lblUpdates.insets = new Insets(0, 0, 5, 0);
    gbc_lblUpdates.gridx = 0;
    gbc_lblUpdates.gridy = 0;
    panel_4.add(lblUpdates, gbc_lblUpdates);
    lblUpdates.setFont(new Font("Lucida Grande", Font.BOLD, 14));
    JScrollPane scrollPane = new JScrollPane();
    GridBagConstraints gbc_scrollPane = new GridBagConstraints();
    gbc_scrollPane.fill = GridBagConstraints.BOTH;
    gbc_scrollPane.gridx = 0;
    gbc_scrollPane.gridy = 1;
    panel_4.add(scrollPane, gbc_scrollPane);
    updatesList = new JList<String>(updateListDM);
    scrollPane.setViewportView(updatesList);
    updatesList.addListSelectionListener(new ListSelectionListener() {

        public void valueChanged(ListSelectionEvent e) {
            if (e.getValueIsAdjusting() == false) {
                if (updatesList.getSelectedIndex() != -1) {
                    String sparql = appProfile.update(updatesList.getSelectedValue());
                    sparql = sparql.replaceFirst("\n", "");
                    sparql = sparql.replaceAll("\t", "");
                    sparql = sparql.trim();
                    SPARQLUpdate.setText(sparql);
                    Bindings bindings = appProfile.updateBindings(updatesList.getSelectedValue());
                    updateForcedBindingsDM.clearBindings();
                    if (bindings == null)
                        return;
                    for (String var : bindings.getVariables()) {
                        updateForcedBindingsDM.addBindings(var, bindings.isLiteral(var));
                    }
                }
            }
        }
    });
    updatesList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    JPanel panel_5 = new JPanel();
    splitPanel_Update.setRightComponent(panel_5);
    GridBagLayout gbl_panel_5 = new GridBagLayout();
    gbl_panel_5.columnWidths = new int[] { 101, 0 };
    gbl_panel_5.rowHeights = new int[] { 16, 0, 0 };
    gbl_panel_5.columnWeights = new double[] { 1.0, Double.MIN_VALUE };
    gbl_panel_5.rowWeights = new double[] { 0.0, 1.0, Double.MIN_VALUE };
    panel_5.setLayout(gbl_panel_5);
    JLabel lblForcedBindings = new JLabel("Forced bindings");
    GridBagConstraints gbc_lblForcedBindings = new GridBagConstraints();
    gbc_lblForcedBindings.anchor = GridBagConstraints.NORTH;
    gbc_lblForcedBindings.insets = new Insets(0, 0, 5, 0);
    gbc_lblForcedBindings.gridx = 0;
    gbc_lblForcedBindings.gridy = 0;
    panel_5.add(lblForcedBindings, gbc_lblForcedBindings);
    JScrollPane scrollPane_2 = new JScrollPane();
    GridBagConstraints gbc_scrollPane_2 = new GridBagConstraints();
    gbc_scrollPane_2.fill = GridBagConstraints.BOTH;
    gbc_scrollPane_2.gridx = 0;
    gbc_scrollPane_2.gridy = 1;
    panel_5.add(scrollPane_2, gbc_scrollPane_2);
    updateForcedBindings = new JTable(updateForcedBindingsDM);
    scrollPane_2.setViewportView(updateForcedBindings);
    JSplitPane splitPanel_Subscribe = new JSplitPane();
    GridBagConstraints gbc_splitPanel_Subscribe = new GridBagConstraints();
    gbc_splitPanel_Subscribe.insets = new Insets(0, 0, 5, 0);
    gbc_splitPanel_Subscribe.fill = GridBagConstraints.BOTH;
    gbc_splitPanel_Subscribe.gridx = 1;
    gbc_splitPanel_Subscribe.gridy = 0;
    primitives.add(splitPanel_Subscribe, gbc_splitPanel_Subscribe);
    JPanel panel_6 = new JPanel();
    splitPanel_Subscribe.setLeftComponent(panel_6);
    GridBagLayout gbl_panel_6 = new GridBagLayout();
    gbl_panel_6.columnWidths = new int[] { 193, 0 };
    gbl_panel_6.rowHeights = new int[] { 17, 72, 0 };
    gbl_panel_6.columnWeights = new double[] { 1.0, Double.MIN_VALUE };
    gbl_panel_6.rowWeights = new double[] { 0.0, 1.0, Double.MIN_VALUE };
    panel_6.setLayout(gbl_panel_6);
    JLabel lblSubscribes = new JLabel("SUBSCRIBEs");
    GridBagConstraints gbc_lblSubscribes = new GridBagConstraints();
    gbc_lblSubscribes.anchor = GridBagConstraints.NORTH;
    gbc_lblSubscribes.insets = new Insets(0, 0, 5, 0);
    gbc_lblSubscribes.gridx = 0;
    gbc_lblSubscribes.gridy = 0;
    panel_6.add(lblSubscribes, gbc_lblSubscribes);
    lblSubscribes.setFont(new Font("Lucida Grande", Font.BOLD, 14));
    JScrollPane scrollPane_3 = new JScrollPane();
    GridBagConstraints gbc_scrollPane_3 = new GridBagConstraints();
    gbc_scrollPane_3.fill = GridBagConstraints.BOTH;
    gbc_scrollPane_3.gridx = 0;
    gbc_scrollPane_3.gridy = 1;
    panel_6.add(scrollPane_3, gbc_scrollPane_3);
    subscribesList = new JList<String>(subscribeListDM);
    subscribesList.addListSelectionListener(new ListSelectionListener() {

        public void valueChanged(ListSelectionEvent e) {
            if (e.getValueIsAdjusting() == false) {
                if (subscribesList.getSelectedIndex() != -1) {
                    String sparql = appProfile.subscribe(subscribesList.getSelectedValue());
                    sparql = sparql.replaceFirst("\n", "");
                    sparql = sparql.replaceAll("\t", "");
                    sparql = sparql.trim();
                    SPARQLSubscribe.setText(sparql);
                }
                Bindings bindings = appProfile.subscribeBindings(subscribesList.getSelectedValue());
                subscribeForcedBindingsDM.clearBindings();
                if (bindings == null)
                    return;
                for (String var : bindings.getVariables()) {
                    subscribeForcedBindingsDM.addBindings(var, bindings.isLiteral(var));
                }
            }
        }
    });
    scrollPane_3.setViewportView(subscribesList);
    subscribesList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    JPanel panel_7 = new JPanel();
    splitPanel_Subscribe.setRightComponent(panel_7);
    GridBagLayout gbl_panel_7 = new GridBagLayout();
    gbl_panel_7.columnWidths = new int[] { 454, 0 };
    gbl_panel_7.rowHeights = new int[] { 16, 126, 0 };
    gbl_panel_7.columnWeights = new double[] { 1.0, Double.MIN_VALUE };
    gbl_panel_7.rowWeights = new double[] { 0.0, 1.0, Double.MIN_VALUE };
    panel_7.setLayout(gbl_panel_7);
    JLabel lblForcedBindings_1 = new JLabel("Forced bindings");
    GridBagConstraints gbc_lblForcedBindings_1 = new GridBagConstraints();
    gbc_lblForcedBindings_1.anchor = GridBagConstraints.NORTH;
    gbc_lblForcedBindings_1.insets = new Insets(0, 0, 5, 0);
    gbc_lblForcedBindings_1.gridx = 0;
    gbc_lblForcedBindings_1.gridy = 0;
    panel_7.add(lblForcedBindings_1, gbc_lblForcedBindings_1);
    JScrollPane scrollPane_1 = new JScrollPane();
    GridBagConstraints gbc_scrollPane_1 = new GridBagConstraints();
    gbc_scrollPane_1.fill = GridBagConstraints.BOTH;
    gbc_scrollPane_1.gridx = 0;
    gbc_scrollPane_1.gridy = 1;
    panel_7.add(scrollPane_1, gbc_scrollPane_1);
    subscribeForcedBindings = new JTable(subscribeForcedBindingsDM);
    scrollPane_1.setViewportView(subscribeForcedBindings);
    JScrollPane scrollPane_Update = new JScrollPane();
    GridBagConstraints gbc_scrollPane_Update = new GridBagConstraints();
    gbc_scrollPane_Update.fill = GridBagConstraints.BOTH;
    gbc_scrollPane_Update.insets = new Insets(0, 0, 5, 5);
    gbc_scrollPane_Update.gridx = 0;
    gbc_scrollPane_Update.gridy = 1;
    primitives.add(scrollPane_Update, gbc_scrollPane_Update);
    SPARQLUpdate = new JTextArea();
    scrollPane_Update.setViewportView(SPARQLUpdate);
    SPARQLUpdate.setLineWrap(true);
    btnUpdate = new JButton("UPDATE");
    btnUpdate.setEnabled(false);
    btnUpdate.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            Bindings forced = new Bindings();
            for (int index = 0; index < updateForcedBindingsDM.getRowCount(); index++) {
                String value = (String) updateForcedBindingsDM.getValueAt(index, 1);
                String var = (String) updateForcedBindingsDM.getValueAt(index, 0);
                boolean literal = (boolean) updateForcedBindingsDM.getValueAt(index, 2);
                if (value.equals("")) {
                    lblInfo.setText("Please specify binding value: " + var);
                    lblInfo.setToolTipText("Please specify binding value: " + var);
                    return;
                }
                if (literal)
                    forced.addBinding(var, new RDFTermLiteral(value));
                else
                    forced.addBinding(var, new RDFTermURI(value));
            }
            String update = SPARQLUpdate.getText().replaceAll("[\n\t]", "");
            long start = System.currentTimeMillis();
            Response result = sepaClient.update(update, forced);
            long stop = System.currentTimeMillis();
            String status = "DONE";
            if (result.isError()) {
                status = "FAILED " + ((ErrorResponse) result).getErrorMessage();
            }
            lblInfo.setText("UPDATE (" + (stop - start) + " ms): " + status);
            lblInfo.setToolTipText("UPDATE (" + (stop - start) + " ms): " + status);
        }
    });
    JScrollPane scrollPane_Subscribe = new JScrollPane();
    GridBagConstraints gbc_scrollPane_Subscribe = new GridBagConstraints();
    gbc_scrollPane_Subscribe.fill = GridBagConstraints.BOTH;
    gbc_scrollPane_Subscribe.insets = new Insets(0, 0, 5, 0);
    gbc_scrollPane_Subscribe.gridx = 1;
    gbc_scrollPane_Subscribe.gridy = 1;
    primitives.add(scrollPane_Subscribe, gbc_scrollPane_Subscribe);
    SPARQLSubscribe = new JTextArea();
    scrollPane_Subscribe.setViewportView(SPARQLSubscribe);
    SPARQLSubscribe.setLineWrap(true);
    GridBagConstraints gbc_btnUpdate = new GridBagConstraints();
    gbc_btnUpdate.insets = new Insets(0, 0, 5, 5);
    gbc_btnUpdate.gridx = 0;
    gbc_btnUpdate.gridy = 2;
    primitives.add(btnUpdate, gbc_btnUpdate);
    JPanel panel = new JPanel();
    GridBagConstraints gbc_panel = new GridBagConstraints();
    gbc_panel.insets = new Insets(0, 0, 5, 0);
    gbc_panel.fill = GridBagConstraints.BOTH;
    gbc_panel.gridx = 1;
    gbc_panel.gridy = 2;
    primitives.add(panel, gbc_panel);
    GridBagLayout gbl_panel = new GridBagLayout();
    gbl_panel.columnWidths = new int[] { 0, 0, 0 };
    gbl_panel.rowHeights = new int[] { 0, 0 };
    gbl_panel.columnWeights = new double[] { 1.0, 1.0, Double.MIN_VALUE };
    gbl_panel.rowWeights = new double[] { 1.0, Double.MIN_VALUE };
    panel.setLayout(gbl_panel);
    btnQuery = new JButton("QUERY");
    btnQuery.setEnabled(false);
    btnQuery.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            Bindings forced = new Bindings();
            for (int index = 0; index < subscribeForcedBindings.getRowCount(); index++) {
                String value = (String) subscribeForcedBindings.getValueAt(index, 1);
                boolean literal = (boolean) subscribeForcedBindings.getValueAt(index, 2);
                String var = (String) subscribeForcedBindings.getValueAt(index, 0);
                if (value.equals("")) {
                    lblInfo.setText("Please specify binding value: " + var);
                    lblInfo.setToolTipText("Please specify binding value: " + var);
                    return;
                }
                if (literal)
                    forced.addBinding(var, new RDFTermLiteral(value));
                else
                    forced.addBinding(var, new RDFTermURI(value));
            }
            String query = SPARQLSubscribe.getText().replaceAll("[\n\t]", "");
            lblInfo.setText("Running query...");
            long start = System.currentTimeMillis();
            response = sepaClient.query(query, forced);
            long stop = System.currentTimeMillis();
            String status = "DONE";
            if (response.isError()) {
                status = "FAILED " + ((ErrorResponse) response).getErrorMessage();
            } else {
                bindingsDM.clear();
                BindingsResults ret = ((QueryResponse) response).getBindingsResults();
                bindingsDM.setAddedResults(ret, null);
                status = " " + ret.size() + " bindings results";
            }
            lblInfo.setText("QUERY (" + (stop - start) + " ms) :" + status);
            lblInfo.setToolTipText("QUERY (" + (stop - start) + " ms) :" + status);
        }
    });
    GridBagConstraints gbc_btnQuery = new GridBagConstraints();
    gbc_btnQuery.insets = new Insets(0, 0, 0, 5);
    gbc_btnQuery.gridx = 0;
    gbc_btnQuery.gridy = 0;
    panel.add(btnQuery, gbc_btnQuery);
    btnSubscribe = new JButton("SUBSCRIBE");
    btnSubscribe.setEnabled(false);
    btnSubscribe.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            if (btnSubscribe.getText().equals("SUBSCRIBE")) {
                Bindings forced = new Bindings();
                for (int index = 0; index < subscribeForcedBindings.getRowCount(); index++) {
                    String value = (String) subscribeForcedBindings.getValueAt(index, 1);
                    boolean literal = (boolean) subscribeForcedBindings.getValueAt(index, 2);
                    String var = (String) subscribeForcedBindings.getValueAt(index, 0);
                    if (value.equals("")) {
                        lblInfo.setText("Please specify binding value: " + var);
                        lblInfo.setToolTipText("Please specify binding value: " + var);
                        return;
                    }
                    ;
                    if (literal)
                        forced.addBinding(var, new RDFTermLiteral(value));
                    else
                        forced.addBinding(var, new RDFTermURI(value));
                }
                String query = SPARQLSubscribe.getText().replaceAll("[\n\t]", "");
                response = sepaClient.subscribe(query, forced);
                if (response.getClass().equals(ErrorResponse.class)) {
                    lblInfo.setText(response.toString());
                    lblInfo.setToolTipText(response.toString());
                    return;
                }
                // SPUID and results
                String spuid = ((SubscribeResponse) response).getSpuid();
                BindingsResults ret = ((SubscribeResponse) response).getBindingsResults();
                // Subscription panel
                JPanel sub = new JPanel();
                // Results label
                JLabel infoLabel = new JLabel();
                infoLabel.setText("Subscribed. First results: " + ret.size());
                subscriptionResultsLabels.put(spuid, infoLabel);
                // Results table
                subscriptionResultsDM.put(spuid, new BindingsTableModel());
                JTable bindingsResultsTable = new JTable(subscriptionResultsDM.get(spuid));
                bindingsResultsTable.setDefaultRenderer(Object.class, bindingsRender);
                bindingsResultsTable.setAutoCreateRowSorter(true);
                bindingsResultsTable.registerKeyboardAction(new CopyAction(), KeyStroke.getKeyStroke(KeyEvent.VK_C, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()), JComponent.WHEN_FOCUSED);
                bindingsResultsTable.setCellSelectionEnabled(true);
                subscriptionResultsTables.put(spuid, bindingsResultsTable);
                subscriptionResultsDM.get(spuid).setAddedResults(ret, spuid);
                JScrollPane bindingsResults = new JScrollPane();
                bindingsResults.setViewportView(bindingsResultsTable);
                // Unsubscribe button
                JButton unsubscribeButton = new JButton(spuid);
                unsubscribeButton.setEnabled(true);
                unsubscribeButton.addActionListener(new ActionListener() {

                    public void actionPerformed(ActionEvent e) {
                        response = sepaClient.unsubscribe(spuid);
                        // if (response.isUnsubscribeResponse()) {
                        subscriptions.remove(sub);
                        subscriptionResultsDM.remove(spuid);
                        subscriptionResultsLabels.remove(spuid);
                        subscriptionResultsTables.remove(spuid);
                    // }
                    }
                });
                // Query label
                JLabel queryLabel = new JLabel("<html>" + query + " forced bindings: " + forced.toString() + "</html>");
                queryLabel.setFont(new Font("Arial", Font.BOLD, 14));
                // Layout
                GridBagConstraints layoutFill = new GridBagConstraints();
                layoutFill.fill = GridBagConstraints.BOTH;
                sub.setLayout(new BoxLayout(sub, BoxLayout.Y_AXIS));
                sub.setName(subscribesList.getSelectedValue());
                // Add components
                sub.add(queryLabel);
                sub.add(unsubscribeButton);
                sub.add(bindingsResults);
                sub.add(infoLabel);
                subscriptions.add(sub, layoutFill);
            }
        }
    });
    GridBagConstraints gbc_btnSubscribe = new GridBagConstraints();
    gbc_btnSubscribe.gridx = 1;
    gbc_btnSubscribe.gridy = 0;
    panel.add(btnSubscribe, gbc_btnSubscribe);
    JScrollPane bindingsResults = new JScrollPane();
    GridBagConstraints gbc_bindingsResults = new GridBagConstraints();
    gbc_bindingsResults.fill = GridBagConstraints.BOTH;
    gbc_bindingsResults.gridwidth = 2;
    gbc_bindingsResults.gridx = 0;
    gbc_bindingsResults.gridy = 3;
    primitives.add(bindingsResults, gbc_bindingsResults);
    bindingsResultsTable = new JTable(bindingsDM);
    bindingsResults.setViewportView(bindingsResultsTable);
    bindingsResultsTable.setDefaultRenderer(Object.class, bindingsRender);
    bindingsResultsTable.setAutoCreateRowSorter(true);
    bindingsResultsTable.registerKeyboardAction(new CopyAction(), KeyStroke.getKeyStroke(KeyEvent.VK_C, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()), JComponent.WHEN_FOCUSED);
    bindingsResultsTable.setCellSelectionEnabled(true);
    subscriptions = new JTabbedPane(JTabbedPane.TOP);
    tabbedPane.addTab("Subscriptions", null, subscriptions, null);
    JPanel namespaces = new JPanel();
    tabbedPane.addTab("Namespaces", null, namespaces, null);
    namespaces.setBorder(new TitledBorder(null, "Namespaces", TitledBorder.LEADING, TitledBorder.TOP, null, null));
    GridBagLayout gbl_namespaces = new GridBagLayout();
    gbl_namespaces.columnWidths = new int[] { 0, 0, 0 };
    gbl_namespaces.rowHeights = new int[] { 43, 0 };
    gbl_namespaces.columnWeights = new double[] { 1.0, 1.0, Double.MIN_VALUE };
    gbl_namespaces.rowWeights = new double[] { 1.0, Double.MIN_VALUE };
    namespaces.setLayout(gbl_namespaces);
    JScrollPane scrollPane_4 = new JScrollPane();
    GridBagConstraints gbc_scrollPane_4 = new GridBagConstraints();
    gbc_scrollPane_4.gridwidth = 2;
    gbc_scrollPane_4.insets = new Insets(0, 0, 0, 5);
    gbc_scrollPane_4.fill = GridBagConstraints.BOTH;
    gbc_scrollPane_4.gridx = 0;
    gbc_scrollPane_4.gridy = 0;
    namespaces.add(scrollPane_4, gbc_scrollPane_4);
    namespacesTable = new JTable(namespacesDM);
    scrollPane_4.setViewportView(namespacesTable);
    JPanel infoPanel = new JPanel();
    GridBagConstraints gbc_infoPanel = new GridBagConstraints();
    gbc_infoPanel.anchor = GridBagConstraints.SOUTH;
    gbc_infoPanel.fill = GridBagConstraints.HORIZONTAL;
    gbc_infoPanel.gridx = 0;
    gbc_infoPanel.gridy = 2;
    frmSepaDashboard.getContentPane().add(infoPanel, gbc_infoPanel);
    GridBagLayout gbl_infoPanel = new GridBagLayout();
    gbl_infoPanel.columnWidths = new int[] { 73, 0, 0, 97, 76, 0 };
    gbl_infoPanel.rowHeights = new int[] { 29, 0 };
    gbl_infoPanel.columnWeights = new double[] { 1.0, 0.0, 0.0, 0.0, 0.0, Double.MIN_VALUE };
    gbl_infoPanel.rowWeights = new double[] { 0.0, Double.MIN_VALUE };
    infoPanel.setLayout(gbl_infoPanel);
    lblInfo = new JLabel("Info");
    GridBagConstraints gbc_lblInfo = new GridBagConstraints();
    gbc_lblInfo.anchor = GridBagConstraints.WEST;
    gbc_lblInfo.insets = new Insets(0, 10, 0, 5);
    gbc_lblInfo.gridx = 0;
    gbc_lblInfo.gridy = 0;
    infoPanel.add(lblInfo, gbc_lblInfo);
    ToolTipManager.sharedInstance().setDismissDelay(Integer.MAX_VALUE);
    chckbxClearonnotify = new JCheckBox("ClearOnNotify");
    chckbxClearonnotify.addChangeListener(new ChangeListener() {

        public void stateChanged(ChangeEvent e) {
        }
    });
    GridBagConstraints gbc_chckbxClearonnotify = new GridBagConstraints();
    gbc_chckbxClearonnotify.insets = new Insets(0, 0, 0, 5);
    gbc_chckbxClearonnotify.gridx = 1;
    gbc_chckbxClearonnotify.gridy = 0;
    infoPanel.add(chckbxClearonnotify, gbc_chckbxClearonnotify);
    JCheckBox chckbxQname = new JCheckBox("Qname");
    chckbxQname.addChangeListener(new ChangeListener() {

        public void stateChanged(ChangeEvent e) {
            bindingsRender.showAsQName(chckbxQname.isSelected());
            bindingsDM.fireTableDataChanged();
            for (BindingsTableModel table : subscriptionResultsDM.values()) {
                table.fireTableDataChanged();
            }
        }
    });
    chckbxQname.setSelected(true);
    GridBagConstraints gbc_chckbxQname = new GridBagConstraints();
    gbc_chckbxQname.insets = new Insets(0, 0, 0, 5);
    gbc_chckbxQname.gridx = 2;
    gbc_chckbxQname.gridy = 0;
    infoPanel.add(chckbxQname, gbc_chckbxQname);
    chckbxAutoscroll = new JCheckBox("Autoscroll");
    GridBagConstraints gbc_chckbxAutoscroll = new GridBagConstraints();
    gbc_chckbxAutoscroll.anchor = GridBagConstraints.WEST;
    gbc_chckbxAutoscroll.insets = new Insets(0, 0, 0, 5);
    gbc_chckbxAutoscroll.gridx = 3;
    gbc_chckbxAutoscroll.gridy = 0;
    infoPanel.add(chckbxAutoscroll, gbc_chckbxAutoscroll);
    chckbxAutoscroll.setSelected(true);
    JButton btnClean = new JButton("Clear");
    GridBagConstraints gbc_btnClean = new GridBagConstraints();
    gbc_btnClean.anchor = GridBagConstraints.NORTHWEST;
    gbc_btnClean.gridx = 4;
    gbc_btnClean.gridy = 0;
    infoPanel.add(btnClean, gbc_btnClean);
    btnClean.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            if (primitives.isShowing()) {
                bindingsDM.clear();
                lblInfo.setText("Results cleaned");
                lblInfo.setToolTipText("Results cleaned");
            } else {
                for (String spuid : subscriptionResultsTables.keySet()) {
                    if (subscriptionResultsTables.get(spuid).isShowing()) {
                        subscriptionResultsDM.get(spuid).clear();
                        subscriptionResultsLabels.get(spuid).setText("Results cleaned");
                    }
                }
            }
        }
    });
    bindingsRender.setNamespaces(namespacesDM);
}
Also used : JPanel(javax.swing.JPanel) GridBagConstraints(java.awt.GridBagConstraints) BindingsResults(it.unibo.arces.wot.sepa.commons.sparql.BindingsResults) ARBindingsResults(it.unibo.arces.wot.sepa.commons.sparql.ARBindingsResults) Insets(java.awt.Insets) JTextArea(javax.swing.JTextArea) GridBagLayout(java.awt.GridBagLayout) ActionEvent(java.awt.event.ActionEvent) DefaultTableModel(javax.swing.table.DefaultTableModel) JTabbedPane(javax.swing.JTabbedPane) BoxLayout(javax.swing.BoxLayout) JButton(javax.swing.JButton) FileNotFoundException(java.io.FileNotFoundException) ListSelectionEvent(javax.swing.event.ListSelectionEvent) RDFTermURI(it.unibo.arces.wot.sepa.commons.sparql.RDFTermURI) TitledBorder(javax.swing.border.TitledBorder) Properties(java.util.Properties) Bindings(it.unibo.arces.wot.sepa.commons.sparql.Bindings) RDFTermLiteral(it.unibo.arces.wot.sepa.commons.sparql.RDFTermLiteral) Font(java.awt.Font) JFrame(javax.swing.JFrame) ChangeListener(javax.swing.event.ChangeListener) JScrollPane(javax.swing.JScrollPane) JLabel(javax.swing.JLabel) IOException(java.io.IOException) ListSelectionListener(javax.swing.event.ListSelectionListener) ErrorResponse(it.unibo.arces.wot.sepa.commons.response.ErrorResponse) QueryResponse(it.unibo.arces.wot.sepa.commons.response.QueryResponse) ErrorResponse(it.unibo.arces.wot.sepa.commons.response.ErrorResponse) Response(it.unibo.arces.wot.sepa.commons.response.Response) SubscribeResponse(it.unibo.arces.wot.sepa.commons.response.SubscribeResponse) JCheckBox(javax.swing.JCheckBox) ActionListener(java.awt.event.ActionListener) JFileChooser(javax.swing.JFileChooser) ChangeEvent(javax.swing.event.ChangeEvent) FileOutputStream(java.io.FileOutputStream) JTable(javax.swing.JTable) JSplitPane(javax.swing.JSplitPane)

Example 40 with ChangeListener

use of javax.swing.event.ChangeListener in project jgnash by ccavanaugh.

the class JideSwingUtilities method synchronizeView.

/**
     * Synchronizes the two viewports. The view position changes in the master view, the slave view's view position will
     * change too. Generally speaking, if you want the two viewports to synchronize vertically, they should have the
     * same height. If horizontally, the same width.
     * <p>
     * It's OK if you call this method with the same master viewport and slave viewport duplicate times. It won't cause
     * multiple events fired.
     *
     * @param masterViewport the master viewport
     * @param slaveViewport  the slave viewport
     * @param orientation    the orientation. It could be either SwingConstants.HORIZONTAL or SwingConstants.VERTICAL.
     */
@SuppressWarnings({ "unchecked", "rawtypes" })
public static void synchronizeView(final JViewport masterViewport, final JViewport slaveViewport, final int orientation) {
    if (masterViewport == null || slaveViewport == null) {
        return;
    }
    ChangeListener[] changeListeners = masterViewport.getChangeListeners();
    int i = 0;
    for (; i < changeListeners.length; i++) {
        if (changeListeners[i] == getViewportSynchronizationChangeListener()) {
            break;
        }
    }
    if (i >= changeListeners.length) {
        masterViewport.addChangeListener(getViewportSynchronizationChangeListener());
    }
    Object property = masterViewport.getClientProperty(JideScrollPane.CLIENT_PROPERTY_SLAVE_VIEWPORT);
    if (!(property instanceof Map)) {
        property = new HashMap<JViewport, Integer>();
    }
    Map<JViewport, Integer> slaveViewportMap = (Map) property;
    slaveViewportMap.put(slaveViewport, orientation);
    masterViewport.putClientProperty(JideScrollPane.CLIENT_PROPERTY_SLAVE_VIEWPORT, slaveViewportMap);
    property = slaveViewport.getClientProperty(JideScrollPane.CLIENT_PROPERTY_MASTER_VIEWPORT);
    if (!(property instanceof Map)) {
        property = new HashMap<JViewport, Integer>();
    }
    Map<JViewport, Integer> masterViewportMap = (Map) property;
    masterViewportMap.put(masterViewport, orientation);
    slaveViewport.putClientProperty(JideScrollPane.CLIENT_PROPERTY_MASTER_VIEWPORT, masterViewportMap);
}
Also used : JViewport(javax.swing.JViewport) ChangeListener(javax.swing.event.ChangeListener) Map(java.util.Map) HashMap(java.util.HashMap) Point(java.awt.Point)

Aggregations

ChangeListener (javax.swing.event.ChangeListener)472 ChangeEvent (javax.swing.event.ChangeEvent)449 ActionEvent (java.awt.event.ActionEvent)170 ActionListener (java.awt.event.ActionListener)164 Dimension (java.awt.Dimension)160 JPanel (javax.swing.JPanel)136 Point (java.awt.Point)108 JLabel (javax.swing.JLabel)98 JSlider (javax.swing.JSlider)69 JButton (javax.swing.JButton)66 JCheckBox (javax.swing.JCheckBox)55 MouseEvent (java.awt.event.MouseEvent)47 BorderLayout (java.awt.BorderLayout)46 GridBagConstraints (java.awt.GridBagConstraints)42 GridBagLayout (java.awt.GridBagLayout)39 MouseAdapter (java.awt.event.MouseAdapter)39 Insets (java.awt.Insets)37 PropertyChangeListener (java.beans.PropertyChangeListener)35 PropertyChangeEvent (java.beans.PropertyChangeEvent)34 ItemEvent (java.awt.event.ItemEvent)33