Example usage for javax.swing JScrollPane setHorizontalScrollBarPolicy

List of usage examples for javax.swing JScrollPane setHorizontalScrollBarPolicy

Introduction

In this page you can find the example usage for javax.swing JScrollPane setHorizontalScrollBarPolicy.

Prototype

@BeanProperty(preferred = true, enumerationValues = { "ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED",
        "ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER",
        "ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS" }, description = "The scrollpane scrollbar policy")
public void setHorizontalScrollBarPolicy(int policy) 

Source Link

Document

Determines when the horizontal scrollbar appears in the scrollpane.

Usage

From source file:org.kepler.gui.DialogGeneralTab.java

/**
 * getCenterPanel/*from ww  w.  ja  va2s  .c o  m*/
 * 
 * @return Component
 */
protected Component getCenterPanel() {
    Box centerPanel = Box.createHorizontalBox();

    final Border middlePanelPaddingBorder = BorderFactory.createEmptyBorder( // top, left, bottom, right
            StaticResources.getSize("dialogs.tabPanels.padding.top", 0), 0, 0, 0);

    centerPanel.setBorder(middlePanelPaddingBorder);

    JLabel noteLbl = WidgetFactory.makeJLabel(
            StaticResources.getDisplayString("dialogs." + _targetType + ".general.note", "Note"),
            TabbedDialog.jLabelDims);
    centerPanel.add(noteLbl);

    noteTxtArea = WidgetFactory.makeJTextArea(_target != null ? _target.getName() : "");
    JScrollPane scrollPane = new JScrollPane(noteTxtArea);
    scrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
    scrollPane.setVerticalScrollBarPolicy(scrollPane.VERTICAL_SCROLLBAR_ALWAYS);
    scrollPane.setWheelScrollingEnabled(true);
    centerPanel.add(scrollPane);

    return centerPanel;
}

From source file:org.kepler.gui.PlotsEditorPanel.java

public PlotsEditorPanel(TableauFrame parent, String title) {
    super();//from  w ww. jav  a 2  s.  co  m
    _title = title;
    _frame = parent;
    setBackground(TabManager.BGCOLOR);
    setLayout(new BoxLayout(this, BoxLayout.PAGE_AXIS));
    plotsPanel = new JPanel();
    plotsPanel.setLayout(new BoxLayout(plotsPanel, BoxLayout.PAGE_AXIS));

    fixGraphics();

    JScrollPane scrollPane = new JScrollPane(plotsPanel);

    scrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
    scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
    this.add(scrollPane, BorderLayout.CENTER);
    JButton addPlotButton = createAddPlotButton();
    this.add(addPlotButton, BorderLayout.PAGE_END);

    // This thread will try to wait until the PlotsPanel is available
    // before adding a plot to it. If a plot is added before the
    // applicable tab pane is available, an NPE will be triggered.
    // The thread will poll for tab pane setup completion every 100 ms,
    // up to a maximum of 10 seconds (100 iterations). If after 10 seconds
    // the tab pane is not available, something has probably gone wrong,
    // and further attempts would do no good.
    new Thread(new Runnable() {
        private void pause(long l) {
            try {
                Thread.sleep(l);
            } catch (InterruptedException ignored) {
            }
        }

        public void run() {
            int maxIterations = 100;
            for (int i = 0; i < maxIterations; i++) {
                log.debug("PlotsEditorPanel thread waiting " + "for TabPane to become available...");
                pause(100);
                if (canAddPlot()) {
                    log.debug("PlotsEditorPanel thread got TabPane, adding Plot.");
                    addPlot();
                    return;
                }
            }
        }
    }).start();
}

From source file:org.nebulaframework.ui.swing.node.NodeMainUI.java

/**
 * Setup Job History Tab Pane//from  w w  w.jav  a  2  s. co m
 * 
 * @return JPanel for History tab
 */
private JPanel setupHistory() {

    JPanel historyPanel = new JPanel();
    historyPanel.setLayout(new BorderLayout(10, 10));

    /* -- Job List  -- */
    JPanel jobListPanel = new JPanel();
    historyPanel.add(jobListPanel, BorderLayout.CENTER);

    jobListPanel.setLayout(new BorderLayout(10, 10));
    jobListPanel.setBorder(BorderFactory.createTitledBorder("Grid Jobs"));

    final JList jobList = new JList(historyList);
    JScrollPane jobListScroll = new JScrollPane(jobList);
    jobListPanel.add(jobListScroll, BorderLayout.CENTER);
    jobListScroll.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
    jobListScroll.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);

    addUIElement("history.joblist", jobList);

    jobList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    jobList.addListSelectionListener(new ListSelectionListener() {

        @Override
        public void valueChanged(ListSelectionEvent e) {

            // Ignore intermediate events
            if (e.getValueIsAdjusting())
                return;

            displayJobInfo(jobList.getSelectedValue());
        }

    });

    JPanel jobInfoPanel = new JPanel();
    historyPanel.add(jobInfoPanel, BorderLayout.SOUTH);

    jobInfoPanel.setLayout(new BorderLayout(10, 10));
    jobInfoPanel.setBorder(BorderFactory.createTitledBorder("Job Information"));

    JPanel centerPanel = new JPanel();

    jobInfoPanel.add(centerPanel, BorderLayout.CENTER);

    centerPanel.setLayout(new GridLayout(0, 4, 10, 10));

    JLabel jobIdLabel = new JLabel("GridJob ID :");
    centerPanel.add(jobIdLabel);
    JLabel jobId = new JLabel("N/A");
    centerPanel.add(jobId);
    addUIElement("history.jobid", jobId); // Add to components map

    JLabel jobNameLabel = new JLabel("GridJob Name :");
    centerPanel.add(jobNameLabel);
    JLabel jobName = new JLabel("N/A");
    centerPanel.add(jobName);
    addUIElement("history.jobname", jobName); // Add to components map

    JLabel startTimeLabel = new JLabel("Start Time :");
    centerPanel.add(startTimeLabel);
    JLabel startTime = new JLabel("N/A");
    centerPanel.add(startTime);
    addUIElement("history.starttime", startTime); // Add to components map

    JLabel durationLabel = new JLabel("Duration :");
    centerPanel.add(durationLabel);
    JLabel duration = new JLabel("N/A");
    centerPanel.add(duration);
    addUIElement("history.duration", duration); // Add to components map

    JLabel tasksLabel = new JLabel("Tasks Executed :");
    centerPanel.add(tasksLabel);
    JLabel tasks = new JLabel("N/A");
    centerPanel.add(tasks);
    addUIElement("history.tasks", tasks); // Add to components map

    JLabel failuresLabel = new JLabel("Failures :");
    centerPanel.add(failuresLabel);
    JLabel failures = new JLabel("N/A");
    centerPanel.add(failures);
    addUIElement("history.failures", failures); // Add to components map

    // Place Holders
    centerPanel.add(new JLabel());
    centerPanel.add(new JLabel());

    return historyPanel;
}

From source file:org.nuclos.client.dbtransfer.DBTransferImport.java

private PanelWizardStep newStep1(final MainFrameTab ifrm) {
    final SpringLocaleDelegate localeDelegate = getSpringLocaleDelegate();
    final PanelWizardStep step = new PanelWizardStep(
            localeDelegate.getMessage("dbtransfer.import.step1.1", "Konfigurationsdatei"),
            localeDelegate.getMessage("dbtransfer.import.step1.2",
                    "Bitte w\u00e4hlen Sie eine Konfigurationsdatei aus."));

    final JLabel lbFile = new JLabel(localeDelegate.getMessage("dbtransfer.import.step1.3", "Datei"));

    utils.initJPanel(step,//from w ww  . j  a  v a 2  s.  co  m
            new double[] { TableLayout.PREFERRED, TableLayout.PREFERRED, TableLayout.PREFERRED,
                    TableLayout.FILL },
            new double[] { 20, TableLayout.PREFERRED, lbFile.getPreferredSize().height, TableLayout.FILL });

    final JButton btnBrowse = new JButton("...");
    //final JProgressBar progressBar = new JProgressBar(0, 230);
    final JCheckBox chbxImportAsNuclon = new JCheckBox(
            localeDelegate.getMessage("configuration.transfer.import.as.nuclon", "Import als Nuclon"));
    chbxImportAsNuclon.setEnabled(false);
    final JEditorPane editWarnings = new JEditorPane();
    editWarnings.setContentType("text/html");
    editWarnings.setEditable(false);
    editWarnings.setBackground(Color.WHITE);

    final JScrollPane scrollWarn = new JScrollPane(editWarnings);
    scrollWarn.setPreferredSize(new Dimension(680, 250));
    scrollWarn.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    scrollWarn.getVerticalScrollBar().setUnitIncrement(20);
    scrollWarn.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    scrollWarn.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);
    final JScrollPane scrollPrev = new JScrollPane(jpnPreviewContent);
    scrollPrev.setPreferredSize(new Dimension(680, 250));
    scrollPrev.setBorder(new LineBorder(Color.LIGHT_GRAY, 1));
    scrollPrev.getVerticalScrollBar().setUnitIncrement(20);
    scrollPrev.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    scrollPrev.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);
    final JPanel jpnPreview = new JPanel(new BorderLayout());
    jpnPreview.add(jpnPreviewHeader, BorderLayout.NORTH);
    jpnPreview.add(scrollPrev, BorderLayout.CENTER);
    jpnPreview.add(jpnPreviewFooter, BorderLayout.SOUTH);
    jpnPreview.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    jpnPreview.setBackground(Color.WHITE);
    jpnPreviewHeader.setBackground(Color.WHITE);
    jpnPreviewContent.setBackground(Color.WHITE);
    jpnPreviewFooter.setBackground(Color.WHITE);

    final JTabbedPane tabbedPane = new JTabbedPane();
    tabbedPane.addTab(localeDelegate.getMessage("configuration.transfer.prepare.warnings.tab", "Warnungen"),
            scrollWarn);
    final String sDefaultPreparePreviewTabText = localeDelegate
            .getMessage("configuration.transfer.prepare.preview.tab", "Vorschau der Schema Aenderungen");
    tabbedPane.addTab(sDefaultPreparePreviewTabText, jpnPreview);

    final JLabel lbNewUser = new JLabel();

    step.add(lbFile, "0,0");
    step.add(tfTransferFile, "1,0");
    step.add(btnBrowse, "2,0");
    step.add(chbxImportAsNuclon, "1,1");//step.add(progressBar, "1,1");
    step.add(lbNewUser, "0,2,3,2");
    step.add(tabbedPane, "0,3,3,3");

    tfTransferFile.setEditable(false);

    final ActionListener prepareImportAction = new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent ev) {
            ifrm.lockLayerWithProgress(Transfer.TOPIC_CORRELATIONID_PREPARE);

            Thread t = new Thread() {
                @Override
                public void run() {
                    step.setComplete(false);
                    boolean blnTransferWithWarnings = false;
                    //progressBar.setValue(0);
                    //progressBar.setVisible(true);
                    try {
                        String fileName = tfTransferFile.getText();
                        if (StringUtils.isNullOrEmpty(fileName)) {
                            return;
                        }
                        File f = new File(fileName);
                        long size = f.length();

                        final InputStream fin = new BufferedInputStream(new FileInputStream(f));
                        final byte[] transferFile;
                        try {
                            transferFile = utils.getBytes(fin, (int) size);
                        } finally {
                            fin.close();
                        }

                        resetStep2();
                        importTransferObject = getTransferFacadeRemote().prepareTransfer(isNuclon,
                                transferFile);
                        chbxImportAsNuclon.setEnabled(importTransferObject.getTransferOptions()
                                .containsKey(TransferOption.IS_NUCLON_IMPORT_ALLOWED));

                        step.setComplete(!importTransferObject.result.hasCriticals());

                        if (!importTransferObject.result.hasCriticals()
                                && !importTransferObject.result.hasWarnings()) {
                            editWarnings.setText(localeDelegate.getMessage(
                                    "configuration.transfer.prepare.no.warnings", "Keine Warnungen"));
                        } else {
                            editWarnings.setText("<html><body><font color=\"#800000\">"
                                    + importTransferObject.result.getCriticals() + "</font>"
                                    + (importTransferObject.result.hasCriticals() ? "<br />" : "")
                                    + importTransferObject.result.getWarnings() + "</body></html>");
                        }

                        int iPreviewSize = importTransferObject.getPreviewParts().size();
                        blnTransferWithWarnings = setupPreviewPanel(importTransferObject.getPreviewParts());
                        tabbedPane.setTitleAt(1, sDefaultPreparePreviewTabText
                                + (iPreviewSize == 0 ? "" : " (" + iPreviewSize + ")"));
                        lbNewUser.setText(
                                "Neue Benutzer" + ": " + (importTransferObject.getNewUserCount() == 0 ? "keine"
                                        : importTransferObject.getNewUserCount()));
                    } catch (Exception e) {
                        //                              progressBar.setVisible(false);
                        Errors.getInstance().showExceptionDialog(ifrm, e);
                    } finally {
                        btnBrowse.setEnabled(true);
                        //                              progressBar.setVisible(false);
                        ifrm.unlockLayer();
                    }
                    if (blnTransferWithWarnings) {
                        JOptionPane.showMessageDialog(jpnPreviewContent, localeDelegate.getMessage(
                                "dbtransfer.import.step1.19",
                                "Nicht alle Statements knnen durchgefhrt werden!\nBitte kontrollieren Sie die mit rot markierten Eintrge!",
                                "Warning", JOptionPane.WARNING_MESSAGE));
                    }
                }

            };

            t.start();
        }
    };
    final ActionListener browseAction = new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent ev) {
            final JFileChooser filechooser = utils.getFileChooser(
                    localeDelegate.getMessage("configuration.transfer.file.nuclet", "Nuclet-Dateien"),
                    ".nuclet");
            final int iBtn = filechooser.showOpenDialog(ifrm);

            if (iBtn == JFileChooser.APPROVE_OPTION) {

                final File file = filechooser.getSelectedFile();
                if (file != null) {
                    tfTransferFile.setText("");
                    btnBrowse.setEnabled(false);
                    //progressBar.setVisible(true);

                    String fileName = file.getPath();
                    if (StringUtils.isNullOrEmpty(fileName)) {
                        return;
                    }

                    tfTransferFile.setText(fileName);

                    prepareImportAction.actionPerformed(new ActionEvent(this, 0, "prepare"));
                }
            }
        }
    };
    final ActionListener importAsNuclonAction = new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            isNuclon = chbxImportAsNuclon.isSelected();
            prepareImportAction.actionPerformed(new ActionEvent(this, 0, "prepare"));
        }
    };
    btnBrowse.addActionListener(browseAction);
    chbxImportAsNuclon.addActionListener(importAsNuclonAction);

    //      progressBar.setVisible(false);

    return step;
}

From source file:org.nuclos.client.dbtransfer.DBTransferImport.java

private PanelWizardStep newStep3(final MainFrameTab ifrm) {
    final SpringLocaleDelegate localeDelegate = getSpringLocaleDelegate();
    final PanelWizardStep step = new PanelWizardStep(
            localeDelegate.getMessage("dbtransfer.import.step3.1", "System Parameter"),
            localeDelegate.getMessage("dbtransfer.import.step3.2",
                    "Bestimmen Sie die Parameter dieses Systems. Sie k\u00f6nnen w\u00e4hlen zwischen dem aktuellen Zustand und dem aus der Konfigurationsdatei importierten Zustand (default). Sollte keine der beiden Vorgaben stimmen, so k\u00f6nnen Sie auch einen anderen Wert setzen.")) {

        @Override/*from  ww  w .ja v a 2s .c  om*/
        public void prepare() {
            setupParameterPanel(importTransferObject.getParameter());
        }

        @Override
        public void applyState() throws InvalidStateException {
            setSelectedIncomingParameter.clear();
            setSelectedCurrentParameter.clear();
            mapSelectedOtherParameter.clear();

            for (ParameterEditor pe : lstParameterEditors) {
                if (pe.isCurrentValue())
                    setSelectedCurrentParameter.add(pe.getName());
                if (pe.isIncomingValue())
                    setSelectedIncomingParameter.add(pe.getName());
                if (pe.isOtherValue())
                    mapSelectedOtherParameter.put(pe.getName(), pe.getValue());
            }
        }
    };
    step.setComplete(true);

    utils.initJPanel(step, new double[] { TableLayout.FILL },
            new double[] { TableLayout.PREFERRED, TableLayout.FILL, TableLayout.PREFERRED });

    rbCurrentAll.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            resetParameterEditors(true);
        }
    });
    rbIncomingAll.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            resetParameterEditors(false);
        }
    });

    final JScrollPane scroll = new JScrollPane(jpnParameter);
    scroll.setPreferredSize(new Dimension(680, 250));
    scroll.setBorder(new LineBorder(Color.LIGHT_GRAY, 1));
    scroll.getVerticalScrollBar().setUnitIncrement(20);
    scroll.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
    scroll.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);
    scroll.getViewport().addChangeListener(new ChangeListener() {
        @Override
        public void stateChanged(ChangeEvent e) {
            Dimension parameterPanelSize = new Dimension(scroll.getViewport().getWidth(),
                    jpnParameter.getPreferredSize().height);
            jpnParameter.setPreferredSize(parameterPanelSize);
        }
    });

    step.add(jpnParameterHeader, "0,0");
    step.add(scroll, "0,1");
    step.add(jpnParameterFooter, "0,2");

    return step;
}

From source file:org.owasp.jbrofuzz.ui.viewers.WindowViewerFrame.java

/**
 * <p>//from w  ww. j  a va  2  s . c  o m
 * The window viewer that gets launched for each request within the
 * corresponding panel.
 * </p>
 * 
 * @param parent The parent panel that the frame will belong to
 * @param name The full file name of the file location to be opened
 * 
 * @author subere@uncon.org
 * @version 2.0
 * @since 2.0
 */
public WindowViewerFrame(final AbstractPanel parent, final String name) {

    super("JBroFuzz - File Viewer - " + name);

    setIconImage(ImageCreator.IMG_FRAME.getImage());

    // The container pane
    final Container pane = getContentPane();
    pane.setLayout(new BorderLayout());

    // Define the Panel
    final JPanel listPanel = new JPanel();
    listPanel.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createTitledBorder(name),
            BorderFactory.createEmptyBorder(1, 1, 1, 1)));
    listPanel.setLayout(new BorderLayout());

    // Get the preferences for wrapping lines of text
    final boolean wrapText = JBroFuzz.PREFS.getBoolean(JBroFuzzPrefs.FUZZING[3].getId(), false);

    if (wrapText) {

        listTextArea = new JTextPane();

    } else {

        listTextArea = new NonWrappingTextPane();

    }

    // Refine the Text Area
    listTextArea.setFont(new Font("Monospaced", Font.PLAIN, 12));
    listTextArea.setEditable(false);

    // Define the search area
    entry = new JTextField(10);
    status = new JLabel("Enter text to search:");

    // Initialise the highlighter on the text area
    hilit = new DefaultHighlighter();
    painter = new DefaultHighlighter.DefaultHighlightPainter(HILIT_COLOR);
    listTextArea.setHighlighter(hilit);

    entryBg = entry.getBackground();
    entry.getDocument().addDocumentListener(this);

    final InputMap im = entry.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
    final ActionMap am = entry.getActionMap();
    im.put(KeyStroke.getKeyStroke("ESCAPE"), CANCEL_ACTION);
    am.put(CANCEL_ACTION, new CancelAction());

    // Right click: Cut, Copy, Paste, Select All
    AbstractPanel.popupText(listTextArea, false, true, false, true);

    // Define the Scroll Pane for the Text Area
    final JScrollPane listTextScrollPane = new JScrollPane(listTextArea);
    listTextScrollPane.setVerticalScrollBarPolicy(20);
    listTextScrollPane.setHorizontalScrollBarPolicy(30);

    // Define the progress bar
    final JProgressBar progressBar = new JProgressBar();
    progressBar.setString("   ");
    progressBar.setStringPainted(true);

    // Define the bottom panel with the progress bar
    final JPanel bottomPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT, 15, 15));
    bottomPanel.add(status);
    bottomPanel.add(entry);
    bottomPanel.add(progressBar);

    listTextArea.setCaretPosition(0);
    // doSyntaxHighlight();
    /*      listTextArea.setEditorKit(new StyledEditorKit() {
            
             private static final long serialVersionUID = -6085642347022880064L;
            
             @Override
             public Document createDefaultDocument() {
    return new TextHighlighter();
             }
            
          });
    */

    listPanel.add(listTextScrollPane);

    // Global Frame Issues
    pane.add(listPanel, BorderLayout.CENTER);
    pane.add(bottomPanel, BorderLayout.SOUTH);

    this.setLocation(parent.getLocationOnScreen().x + 100, parent.getLocationOnScreen().y + 20);
    this.setSize(SIZE_X, SIZE_Y);

    setResizable(true);
    setVisible(true);
    setMinimumSize(new Dimension(SIZE_X, SIZE_Y));
    setDefaultCloseOperation(2);

    listTextArea.addKeyListener(new KeyAdapter() {
        @Override
        public void keyPressed(final KeyEvent ke) {
            if (ke.getKeyCode() == 27) {
                WindowViewerFrame.this.dispose();
            }
            if (ke.getKeyCode() == 10) {
                search();
            }
        }
    });

    entry.addKeyListener(new KeyAdapter() {
        @Override
        public void keyPressed(final KeyEvent ke) {
            if (ke.getKeyCode() == 10) {
                search();
            }
        }
    });

    class FileLoader extends SwingWorker<String, Object> { // NO_UCD

        @Override
        public String doInBackground() {

            progressBar.setIndeterminate(true);

            String dbType = JBroFuzz.PREFS.get(JBroFuzzPrefs.DBSETTINGS[11].getId(), "-1");

            if (dbType.equals("SQLite") || dbType.equals("CouchDB")) {

                String sessionId = parent.getFrame().getJBroFuzz().getWindow().getPanelFuzzing()
                        .getSessionName();

                if (sessionId == null || sessionId.equals("null")) {
                    sessionId = JBroFuzz.PREFS.get("sessionId", "");
                }

                Logger.log("Reading Session: " + sessionId + " with name: " + name, 3);

                MessageContainer mc = parent.getFrame().getJBroFuzz().getStorageHandler()
                        .readFuzzFile(name, sessionId, parent.getFrame().getJBroFuzz().getWindow()).get(0);

                listTextArea.setText("Date: " + mc.getEndDateFull() + "\n" + "FileName: " + mc.getFileName()
                        + "\n" + "URL: " + mc.getTextURL() + "\n" + "Payload: " + mc.getPayload() + "\n"
                        + "EncodedPayload: " + mc.getEncodedPayload() + "\n" + "TextRequest:"
                        + mc.getTextRequest() + "\n" + "Message: " + mc.getMessage() + "\n" + "Status: "
                        + mc.getStatus() + "\n"

                );

            } else {
                Logger.log("Loading data from file", 3);
                final File inputFile = new File(parent.getFrame().getJBroFuzz().getWindow().getPanelFuzzing()
                        .getFrame().getJBroFuzz().getStorageHandler().getLocationURIString(), name + ".html");

                listTextArea.setText(

                        FileHandler.readFile(inputFile)

                );
            }
            return "done";
        }

        @Override
        protected void done() {
            progressBar.setIndeterminate(false);
            progressBar.setValue(100);
            listTextArea.repaint();
        }
    }

    (new FileLoader()).execute();

}

From source file:org.pentaho.reporting.designer.core.ReportDesignerFrame.java

private JComponent createPaletteToolBar() {
    final JToolBar toolBar = new JToolBar();
    toolBar.setFloatable(false);//from  w  w w.j av a2s .c om
    toolBar.setOrientation(JToolBar.VERTICAL);

    final ElementMetaData[] datas = ElementTypeRegistry.getInstance().getAllElementTypes();
    Arrays.sort(datas, new GroupedMetaDataComparator());
    Object grouping = null;
    boolean firstElement = true;
    for (int i = 0; i < datas.length; i++) {
        final ElementMetaData data = datas[i];
        if (data.isHidden()) {
            continue;
        }

        if (!WorkspaceSettings.getInstance().isVisible(data)) {
            continue;
        }

        final String currentGrouping = data.getGrouping(Locale.getDefault());
        if (firstElement == false) {
            if (ObjectUtilities.equal(currentGrouping, grouping) == false) {
                grouping = currentGrouping;
                toolBar.addSeparator();
            }
        } else {
            grouping = currentGrouping;
            firstElement = false;
        }
        final InsertElementAction action = new InsertElementAction(data);
        action.setReportDesignerContext(context);
        toolBar.add(new PaletteButton(data, context));
    }

    final JScrollPane paletteScrollpane = new JScrollPane(toolBar);
    paletteScrollpane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
    paletteScrollpane
            .addComponentListener(new ScrollbarSyncHandler(paletteScrollpane.getVerticalScrollBar(), toolBar));
    return paletteScrollpane;
}

From source file:org.pmedv.blackboard.commands.CreateBoardCommand.java

@Override
public void execute(ActionEvent e) {

    final ApplicationContext ctx = AppContext.getContext();
    final ApplicationWindowAdvisor advisor = ctx.getBean(ApplicationWindowAdvisor.class);
    final ApplicationWindow win = ctx.getBean(ApplicationWindow.class);

    /*// w w w .  j a  v  a  2 s  .  c  om
     * Get the resource service
     */

    final ResourceService resources = ctx.getBean(ResourceService.class);

    /*
     * The infonode docking framework must be invoked later since swing is
     * not thread safe.
     */

    SwingUtilities.invokeLater(new Runnable() {

        @Override
        public void run() {

            BoardEditorModel model = new BoardEditorModel();
            model.addDefaultLayers();
            model.setWidth(IOUtils.BOARD_DEFAULT_WIDTH);
            model.setHeight(IOUtils.BOARD_DEFAULT_HEIGHT);

            String title = resources.getResourceByKey("CreateBoardCommand.name");
            String subTitle = resources.getResourceByKey("CreateBoardCommand.dialog.subtitle");

            BoardPropertiesDialog bpd = new BoardPropertiesDialog(title, subTitle,
                    resources.getIcon("icon.dialog.board"), model);
            bpd.setVisible(true);

            if (bpd.getResult() == AbstractNiceDialog.OPTION_CANCEL)
                return;

            final BoardEditor editor = new BoardEditor(model);

            // the center panel centers the editor inside the view no matter which dimensions it has
            CenterPanel panel = new CenterPanel();
            // go for the zoom
            JXLayer<?> zoomLayer = TransformUtils.createTransformJXLayer(editor, 1, new QualityHints());
            panel.getCenterPanel().add(zoomLayer);
            editor.setZoomLayer(zoomLayer);
            panel.setBoardEditor(editor);
            // put the panel into a scroll pane
            JScrollPane s = new JScrollPane(panel);
            s.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
            s.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
            s.getVerticalScrollBar().setUnitIncrement(512);
            // create new view and connect the view with the editor
            editorView = new View(title, resources.getIcon("icon.editor"), s);
            editor.setView(editorView);
            editor.setFileState(FileState.NEW_AND_UNSAVED);
            editor.setCurrentFile(null);
            // check all available open views
            ArrayList<View> views = EditorUtils.getCurrentPerspectiveViews(advisor.getCurrentPerspective());

            // we need this index for a new untitled view
            int lastUntitledIndex = 0;

            for (View v : views) {
                // found a view with an untitled editor
                if (v.getViewProperties().getTitle().startsWith("untitled")) {
                    // select index if it's greater than the last
                    int index = 0;

                    if (v.getViewProperties().getTitle().contains("*")) {
                        int end = v.getViewProperties().getTitle().lastIndexOf("*");
                        index = Integer.valueOf(v.getViewProperties().getTitle().substring(8, end));
                    } else {
                        index = Integer.valueOf(v.getViewProperties().getTitle().substring(8));
                    }

                    if (index > lastUntitledIndex)
                        lastUntitledIndex = index;
                }
            }
            // and finally add one in order to get the right name
            lastUntitledIndex++;

            editor.getView().getViewProperties().setTitle("untitled" + lastUntitledIndex);
            final int index = editor.getView().hashCode();

            EditorUtils.registerEditorListeners(editor);

            openEditor(editorView, index);

            log.info("Opening editor : " + title);

            // notifies the GUI about the editor change if a tab is switched by the mouse
            editorView.addTabMouseButtonListener(new MouseButtonListener() {

                @Override
                public void mouseButtonEvent(MouseEvent e) {
                    handleMouseEvent(e, editor);
                }

            });
            // wee need to know if a mouse click inside an editor occurs
            editor.addMouseListener(new MouseAdapter() {

                @Override
                public void mousePressed(MouseEvent e) {
                    handleMouseEvent(e, editor);
                }

            });
            // This listener handles the close of an editor tab
            editorView.addListener(new DockingWindowAdapter() {

                @Override
                public void windowClosing(DockingWindow arg0) throws OperationAbortedException {

                    if (editor != null)

                        if (editor.getFileState().equals(FileState.DIRTY)) {
                            int result = JOptionPane.showConfirmDialog(win,
                                    resources.getResourceByKey("msg.warning.notsaved"),
                                    resources.getResourceByKey("msg.warning"), JOptionPane.YES_NO_OPTION,
                                    JOptionPane.QUESTION_MESSAGE);

                            if (result == JOptionPane.NO_OPTION) {
                                throw new OperationAbortedException("Aborted.");
                            }
                        }

                    advisor.getCurrentPerspective().getViewMap().removeView(index);
                    editor.notifyListeners(EventType.EDITOR_CLOSED);
                }

                @Override
                public void windowClosed(DockingWindow window) {
                    editor.notifyListeners(EventType.EDITOR_CLOSED);
                }
            });
            editor.updateStatusBar();
            editor.notifyListeners(EventType.EDITOR_CHANGED);
            ctx.getBean(SetSelectModeCommand.class).execute(null);
        }
    });

}

From source file:org.pmedv.blackboard.commands.CreatePartListCommand.java

@Override
public void execute(ActionEvent e) {
    ApplicationContext ctx = AppContext.getContext();
    final ApplicationWindow win = ctx.getBean(ApplicationWindow.class);
    final BoardEditor editor = EditorUtils.getCurrentActiveEditor();
    StringBuffer partList = new StringBuffer();
    partList.append("Name,Value,Package\n");
    for (Layer layer : editor.getModel().getLayers()) {
        for (Item i : layer.getItems()) {
            if (i instanceof Part && !(i instanceof TextPart)) {
                Part p = (Part) i;/* w ww  .  j a  v a2 s.  com*/
                partList.append(p.getName() + "," + p.getValue() + "," + p.getPackageType() + "\n");
            }
            if (i instanceof Resistor) {
                Resistor r = (Resistor) i;
                partList.append(r.getName() + "," + r.getValue() + " Ohm,RESISTOR\n");
            }
        }
    }
    final JFileChooser fc = new JFileChooser(".");
    fc.setFileFilter(new CSVFilter());
    fc.setDialogTitle(resources.getResourceByKey("CreatePartListCommand.dialog.subtitle"));
    fc.setApproveButtonText(resources.getResourceByKey("msg.save"));
    int result = fc.showOpenDialog(win);
    if (result == JFileChooser.APPROVE_OPTION) {
        if (fc.getSelectedFile() == null)
            return;
        File selectedFile = fc.getSelectedFile();
        if (selectedFile != null) {
            // if csv extension is missing...
            if (!selectedFile.getName().endsWith(".csv")) {
                selectedFile = new File(selectedFile.getAbsolutePath() + ".csv");
            }
            try {
                FileUtils.writeStringToFile(selectedFile, partList.toString(), "UTF-8");
                int res = JOptionPane.showConfirmDialog(win, resources.getResourceByKey("msg.viewpartlist"),
                        resources.getResourceByKey("msg.question"), JOptionPane.YES_NO_OPTION);
                if (res == JOptionPane.YES_OPTION) {
                    JTextArea textPane = new JTextArea();
                    textPane.setText(partList.toString());
                    JScrollPane s = new JScrollPane(textPane);
                    s.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
                    s.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
                    View v = new View("Partlist for " + editor.getCurrentFile().getName(), null, s);
                    editor.setView(v);
                    final ImageIcon icon = resources.getIcon("icon.document.html");
                    v.getViewProperties().setIcon(icon);
                    v.getViewProperties().setTitle("Partlist for " + editor.getCurrentFile().getName());
                    openEditor(v, editor.getCurrentFile().hashCode());
                    v.undock(new Point(20, 10));
                }
            } catch (IOException e1) {
                ErrorUtils.showErrorDialog(e1);
            }
        }
    }
}

From source file:org.pmedv.blackboard.commands.OpenBoardCommand.java

public void doOpen() {

    final ApplicationContext ctx = AppContext.getContext();
    final ApplicationWindowAdvisor advisor = ctx.getBean(ApplicationWindowAdvisor.class);

    BoardEditorModel model = null;//from  www .  j av a 2  s .c o m

    String filename = file.getName().toLowerCase();

    try {
        if (filename.endsWith(".bb") || filename.endsWith(".bbs")) {
            File input;
            try {
                input = IOUtils.unpackBoard(file);
            } catch (Exception e1) {
                ErrorUtils.showErrorDialog(e1);
                return;
            }
            model = IOUtils.openBoard(input);
        } else // legacy xml support
            model = IOUtils.openBoard(file);
    } catch (Exception e1) {
        ErrorUtils.showErrorDialog(e1);
        file = null;
        return;
    }
    if (model == null) {
        ErrorUtils.showErrorDialog(
                new Exception(resources.getResourceByKey("OpenBoardCommand.error") + " : " + file.getName()));
        file = null;
        return;
    }

    final BoardEditor editor = new BoardEditor(model);
    CenterPanel panel = new CenterPanel();
    JXLayer<?> zoomLayer = TransformUtils.createTransformJXLayer(editor, 1, new QualityHints());
    panel.getCenterPanel().add(zoomLayer);
    editor.setZoomLayer(zoomLayer);
    panel.setBoardEditor(editor);
    JScrollPane s = new JScrollPane(panel);
    s.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
    s.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    editorView = new View(title, resources.getIcon("icon.editor"), s);
    editor.setView(editorView);
    editor.setCurrentFile(file);
    editor.setFileState(FileState.OPENED);

    EditorUtils.registerEditorListeners(editor);

    editorView.getViewProperties().setTitle(file.getName());
    try {
        IOUtils.updateRecentFiles(file.getAbsolutePath());
    } catch (Exception e1) {
        ErrorUtils.showErrorDialog(e1);
    }
    openEditor(editorView, editor.getCurrentFile().hashCode());
    if (!fromRecentFileList)
        file = null;
    editorView.addTabMouseButtonListener(new MouseButtonListener() {
        @Override
        public void mouseButtonEvent(MouseEvent e) {
            handleMouseEvent(e, editor);
        }
    });
    editor.addMouseListener(new MouseAdapter() {
        @Override
        public void mousePressed(MouseEvent e) {
            handleMouseEvent(e, editor);
        }
    });
    editorView.addListener(new DockingWindowAdapter() {
        @Override
        public void windowClosing(DockingWindow arg0) throws OperationAbortedException {
            if (editor.getFileState().equals(FileState.DIRTY)) {
                int result = JOptionPane.showConfirmDialog(ctx.getBean(ApplicationWindow.class),
                        resources.getResourceByKey("msg.warning.notsaved"),
                        resources.getResourceByKey("msg.warning"), JOptionPane.YES_NO_OPTION,
                        JOptionPane.QUESTION_MESSAGE);
                if (result == JOptionPane.NO_OPTION) {
                    throw new OperationAbortedException("Aborted.");
                }
            }
            log.info("Removing view with index " + editor.getCurrentFile().hashCode() + " from perspective "
                    + advisor.getCurrentPerspective().ID);
            advisor.getCurrentPerspective().getViewMap().removeView(editor.getCurrentFile().hashCode());
            editor.notifyListeners(EventType.EDITOR_CLOSED);
        }

        @Override
        public void windowClosed(DockingWindow window) {
            editor.notifyListeners(EventType.EDITOR_CLOSED);
        }

    });
    editor.updateStatusBar();
    editor.notifyListeners(EventType.EDITOR_CHANGED);
    ctx.getBean(SetSelectModeCommand.class).execute(null);
}