Example usage for javax.swing SwingConstants LEFT

List of usage examples for javax.swing SwingConstants LEFT

Introduction

In this page you can find the example usage for javax.swing SwingConstants LEFT.

Prototype

int LEFT

To view the source code for javax.swing SwingConstants LEFT.

Click Source Link

Document

Box-orientation constant used to specify the left side of a box.

Usage

From source file:org.eclipse.wb.tests.designer.core.model.property.editor.StaticFieldPropertyEditorTest.java

/**
 * Test for {@link StaticFieldPropertyEditor#configure(EditorState, java.util.Map)}.<br>
 * Fields in single {@link String} as <code>"fields"</code> parameter.
 *//*from w  w  w.j a v a 2s. co m*/
public void test_configure_6() throws Exception {
    parseContainer("// filler filler filler", "public class Test extends JPanel {", "  public Test() {", "  }",
            "}");
    // create StaticFieldPropertyEditor
    StaticFieldPropertyEditor editor = new StaticFieldPropertyEditor();
    editor.configure(m_lastState,
            ImmutableMap.<String, Object>of("class", "javax.swing.SwingConstants", "fields", "LEFT RIGHT"));
    // check state
    Class<?> e_class = SwingConstants.class;
    String m_classSourceName = "javax.swing.SwingConstants";
    Object[] e_names = new String[] { "LEFT", "RIGHT" };
    Object[] e_titles = new String[] { "LEFT", "RIGHT" };
    Object[] e_values = new Object[] { SwingConstants.LEFT, SwingConstants.RIGHT };
    assertConfiguration(editor, e_class, m_classSourceName, e_names, e_titles, e_values);
}

From source file:org.eclipse.wb.tests.designer.core.model.property.editor.StaticFieldPropertyEditorTest.java

/**
 * Test for {@link StaticFieldPropertyEditor#configure(EditorState, java.util.Map)}.<br>
 * Fields in {@link List} as <code>"field"</code> parameter.
 */// w  ww.  java 2 s.c  om
public void test_configure_7() throws Exception {
    parseContainer("// filler filler filler", "public class Test extends JPanel {", "  public Test() {", "  }",
            "}");
    // create StaticFieldPropertyEditor
    StaticFieldPropertyEditor editor = new StaticFieldPropertyEditor();
    editor.configure(m_lastState, ImmutableMap.<String, Object>of("class", "javax.swing.SwingConstants",
            "field", ImmutableList.of("LEFT", "RIGHT")));
    // check state
    Class<?> e_class = SwingConstants.class;
    String m_classSourceName = "javax.swing.SwingConstants";
    Object[] e_names = new String[] { "LEFT", "RIGHT" };
    Object[] e_titles = new String[] { "LEFT", "RIGHT" };
    Object[] e_values = new Object[] { SwingConstants.LEFT, SwingConstants.RIGHT };
    assertConfiguration(editor, e_class, m_classSourceName, e_names, e_titles, e_values);
}

From source file:org.eclipse.wb.tests.designer.core.model.property.editor.StaticFieldPropertyEditorTest.java

/**
 * Test for {@link StaticFieldPropertyEditor#getValueSource(Object)}.
 *//*from   ww  w.  j  ava  2 s  . co  m*/
public void test_getValueSource() throws Exception {
    StaticFieldPropertyEditor editor = new StaticFieldPropertyEditor();
    editor.configure(SwingConstants.class, new String[] { "LEFT", "*remove", "RIGHT" });
    //
    assertEquals("javax.swing.SwingConstants.LEFT", editor.getValueSource(SwingConstants.LEFT));
    assertNull(editor.getValueSource(null));
    assertEquals("javax.swing.SwingConstants.RIGHT", editor.getValueSource(SwingConstants.RIGHT));
    assertNull(editor.getValueSource(SwingConstants.NORTH));
}

From source file:org.eclipse.wb.tests.designer.core.model.property.editor.StaticFieldPropertyEditorTest.java

/**
 * Test for {@link StaticFieldPropertyEditor#getText(Property)}.
 *///from  w ww . j a va 2  s  . c om
public void test_getText() throws Exception {
    StaticFieldPropertyEditor editor = new StaticFieldPropertyEditor();
    editor.configure(SwingConstants.class, new String[] { "LEFT:asLeft", "*remove", "RIGHT" });
    // prepare for mocking
    IMocksControl mocksControl = EasyMock.createStrictControl();
    Property property = mocksControl.createMock(Property.class);
    // LEFT:asLeft
    {
        mocksControl.reset();
        expect(property.getValue()).andReturn(SwingConstants.LEFT);
        mocksControl.replay();
        //
        assertEquals("asLeft", editor.getText(property));
        mocksControl.verify();
    }
    // RIGHT
    {
        mocksControl.reset();
        expect(property.getValue()).andReturn(SwingConstants.RIGHT);
        mocksControl.replay();
        //
        assertEquals("RIGHT", editor.getText(property));
        mocksControl.verify();
    }
    // UNKNOWN_VALUE
    {
        mocksControl.reset();
        expect(property.getValue()).andReturn(Property.UNKNOWN_VALUE);
        mocksControl.replay();
        //
        assertEquals(null, editor.getText(property));
        mocksControl.verify();
    }
}

From source file:org.eclipse.wb.tests.designer.core.model.property.editor.StaticFieldPropertyEditorTest.java

/**
 * Test for {@link StaticFieldPropertyEditor#getClipboardSource(GenericProperty)}.
 *///w w w. j  a  v  a2 s .co  m
public void test_getClipboardSource() throws Exception {
    StaticFieldPropertyEditor editor = new StaticFieldPropertyEditor();
    editor.configure(SwingConstants.class, new String[] { "LEFT", "RIGHT" });
    // prepare for mocking
    IMocksControl mocksControl = EasyMock.createStrictControl();
    GenericProperty property = mocksControl.createMock(GenericProperty.class);
    // LEFT
    {
        mocksControl.reset();
        expect(property.getValue()).andReturn(SwingConstants.LEFT);
        mocksControl.replay();
        //
        assertEquals("javax.swing.SwingConstants.LEFT", editor.getClipboardSource(property));
        mocksControl.verify();
    }
}

From source file:org.eclipse.wb.tests.designer.core.model.property.editor.StaticFieldPropertyEditorTest.java

/**
 * Test for {@link StaticFieldPropertyEditor#setValue(Property, Object)}.<br>
 * For {@link GenericProperty}./*from   www  . ja  v  a  2s  .c o m*/
 */
public void test_setValue_1() throws Exception {
    StaticFieldPropertyEditor editor = new StaticFieldPropertyEditor();
    editor.configure(SwingConstants.class, new String[] { "LEFT", "RIGHT" });
    // prepare for mocking
    IMocksControl mocksControl = EasyMock.createStrictControl();
    GenericProperty property = mocksControl.createMock(GenericProperty.class);
    // LEFT
    {
        mocksControl.reset();
        property.setExpression("javax.swing.SwingConstants.LEFT", SwingConstants.LEFT);
        mocksControl.replay();
        //
        editor.setValue(property, SwingConstants.LEFT);
        mocksControl.verify();
    }
}

From source file:org.eclipse.wb.tests.designer.core.model.property.editor.StaticFieldPropertyEditorTest.java

/**
 * Test for {@link StaticFieldPropertyEditor#setValue(Property, Object)}.<br>
 * For simple {@link Property}./*w w w  .j  a va2 s. co  m*/
 */
public void test_setValue_2() throws Exception {
    StaticFieldPropertyEditor editor = new StaticFieldPropertyEditor();
    editor.configure(SwingConstants.class, new String[] { "LEFT", "RIGHT" });
    // prepare for mocking
    IMocksControl mocksControl = EasyMock.createStrictControl();
    Property property = mocksControl.createMock(Property.class);
    // LEFT
    {
        mocksControl.reset();
        property.setValue(SwingConstants.LEFT);
        mocksControl.replay();
        //
        editor.setValue(property, SwingConstants.LEFT);
        mocksControl.verify();
    }
}

From source file:org.eobjects.datacleaner.panels.OpenAnalysisJobPanel.java

public OpenAnalysisJobPanel(final FileObject file, final AnalyzerBeansConfiguration configuration,
        final OpenAnalysisJobActionListener openAnalysisJobActionListener) {
    super(WidgetUtils.BG_COLOR_LESS_BRIGHT, WidgetUtils.BG_COLOR_LESS_BRIGHT);
    _file = file;// ww w .  j a v  a 2  s  .co  m
    _openAnalysisJobActionListener = openAnalysisJobActionListener;

    setLayout(new BorderLayout());
    setBorder(WidgetUtils.BORDER_LIST_ITEM);

    final AnalysisJobMetadata metadata = getMetadata(configuration);
    final String jobName = metadata.getJobName();
    final String jobDescription = metadata.getJobDescription();
    final String datastoreName = metadata.getDatastoreName();

    final boolean isDemoJob = isDemoJob(metadata);

    final DCPanel labelListPanel = new DCPanel();
    labelListPanel.setLayout(new VerticalLayout(4));
    labelListPanel.setBorder(new EmptyBorder(4, 4, 4, 0));

    final String title;
    final String filename = file.getName().getBaseName();
    if (Strings.isNullOrEmpty(jobName)) {
        final String extension = FileFilters.ANALYSIS_XML.getExtension();
        if (filename.toLowerCase().endsWith(extension)) {
            title = filename.substring(0, filename.length() - extension.length());
        } else {
            title = filename;
        }
    } else {
        title = jobName;
    }

    final JButton titleButton = new JButton(title);
    titleButton.setFont(WidgetUtils.FONT_HEADER1);
    titleButton.setForeground(WidgetUtils.BG_COLOR_BLUE_MEDIUM);
    titleButton.setHorizontalAlignment(SwingConstants.LEFT);
    titleButton.setBorder(BorderFactory.createMatteBorder(0, 0, 1, 0, WidgetUtils.BG_COLOR_MEDIUM));
    titleButton.setToolTipText("Open job");
    titleButton.setOpaque(false);
    titleButton.setMargin(new Insets(0, 0, 0, 0));
    titleButton.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
    titleButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            if (isDemoDatastoreConfigured(datastoreName, configuration)) {
                _openAnalysisJobActionListener.openFile(_file);
            }
        }
    });

    final JButton executeButton = new JButton(executeIcon);
    executeButton.setOpaque(false);
    executeButton.setToolTipText("Execute job directly");
    executeButton.setMargin(new Insets(0, 0, 0, 0));
    executeButton.setBorderPainted(false);
    executeButton.setHorizontalAlignment(SwingConstants.RIGHT);
    executeButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            if (isDemoDatastoreConfigured(datastoreName, configuration)) {
                final ImageIcon executeIconLarge = ImageManager.get().getImageIcon(IconUtils.ACTION_EXECUTE);
                final String question = "Are you sure you want to execute the job\n'" + title + "'?";
                final int choice = JOptionPane.showConfirmDialog(null, question, "Execute job?",
                        JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, executeIconLarge);
                if (choice == JOptionPane.YES_OPTION) {
                    final Injector injector = _openAnalysisJobActionListener.openAnalysisJob(_file);
                    if (injector != null) {
                        final ResultWindow resultWindow = injector.getInstance(ResultWindow.class);
                        resultWindow.open();
                        resultWindow.startAnalysis();
                    }
                }
            }
        }
    });

    final DCPanel titlePanel = new DCPanel();
    titlePanel.setLayout(new BorderLayout());
    titlePanel.add(DCPanel.around(titleButton), BorderLayout.CENTER);
    titlePanel.add(executeButton, BorderLayout.EAST);

    labelListPanel.add(titlePanel);

    if (!Strings.isNullOrEmpty(jobDescription)) {
        String desc = StringUtils.replaceWhitespaces(jobDescription, " ");
        desc = StringUtils.replaceAll(desc, "  ", " ");
        final JLabel label = new JLabel(desc);
        label.setFont(WidgetUtils.FONT_SMALL);
        labelListPanel.add(label);
    }

    final Icon icon;
    {
        if (!StringUtils.isNullOrEmpty(datastoreName)) {
            final JLabel label = new JLabel(" " + datastoreName);
            label.setFont(WidgetUtils.FONT_SMALL);
            labelListPanel.add(label);

            final Datastore datastore = configuration.getDatastoreCatalog().getDatastore(datastoreName);
            if (isDemoJob) {
                icon = demoBadgeIcon;
            } else {
                icon = IconUtils.getDatastoreSpecificAnalysisJobIcon(datastore);
            }
        } else {
            icon = ImageManager.get().getImageIcon(IconUtils.MODEL_JOB, IconUtils.ICON_SIZE_LARGE);
        }
    }

    final JLabel iconLabel = new JLabel(icon);
    iconLabel.setPreferredSize(new Dimension(icon.getIconWidth(), icon.getIconHeight()));

    add(iconLabel, BorderLayout.WEST);
    add(labelListPanel, BorderLayout.CENTER);
}

From source file:org.fhaes.gui.AnalysisResultsPanel.java

/**
 * Draw the analysis results table depending on the current tree-node forcing the GUI to refresh regardless
 * /*  w  w w. j  a va  2 s.  c o  m*/
 * @param forceRefresh
 */
public void setupTable(Boolean forceRefresh) {

    cl.show(cards, RESULTSPANEL);
    MainWindow.getInstance().getReportPanel().actionResultsHelp.setEnabled(true);

    goldFishPanel.setParamsText();

    try {
        log.debug("Setting cursor to wait");
        table.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
        treeResults.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));

        DefaultMutableTreeNode selectednode = (DefaultMutableTreeNode) treeResults
                .getLastSelectedPathComponent();

        if (selectednode == null) {
            clearTable();
            return;
        }

        log.debug("Node selected: " + selectednode.toString());

        // If selection hasn't changed don't do anything
        if (previouslySelectedNode != null && selectednode.equals(previouslySelectedNode) && !forceRefresh) {
            log.debug("Node selection hasn't changed so not doing anything");
            return;
        }

        previouslySelectedNode = selectednode;

        if (!(selectednode instanceof FHAESResultTreeNode)) {
            clearTable();
            return;
        }

        FHAESResultTreeNode resultnode = (FHAESResultTreeNode) treeResults.getLastSelectedPathComponent();

        FHAESResult result = resultnode.getFHAESResult();
        panelResult.setBorder(new TitledBorder(null, result.getFullName(), TitledBorder.LEADING,
                TitledBorder.TOP, null, null));

        if (result.equals(FHAESResult.SEASONALITY_SUMMARY)) {

            log.debug("Seasonality summary node selected");

            if (seasonalitySummaryModel == null) {
                clearTable();
                return;
            }

            table.setModel(seasonalitySummaryModel);
            // table.setSortOrder(0, SortOrder.ASCENDING);
            setDefaultTableAlignment(SwingConstants.RIGHT);
        }

        else if (result.equals(FHAESResult.INTERVAL_SUMMARY)) {

            log.debug("Interval summary node selected");

            if (intervalsSummaryModel == null) {
                clearTable();
                return;
            }

            table.setModel(intervalsSummaryModel);
            // table.setSortOrder(0, SortOrder.ASCENDING);
            setDefaultTableAlignment(SwingConstants.RIGHT);

        }

        else if (result.equals(FHAESResult.INTERVAL_EXCEEDENCE_TABLE)) {

            log.debug("Interval exceedence node selected");

            if (intervalsExceedenceModel == null) {
                clearTable();
                return;
            }

            table.setModel(intervalsExceedenceModel);
            // table.setSortOrder(0, SortOrder.ASCENDING);
            setDefaultTableAlignment(SwingConstants.RIGHT);
        }

        else if (result.equals(FHAESResult.BINARY_MATRIX_00)) {

            if (this.bin00Model == null) {
                clearTable();
                return;
            }

            table.setModel(bin00Model);
            // table.setSortOrder(0, SortOrder.ASCENDING);
            setDefaultTableAlignment(SwingConstants.RIGHT);
        }

        else if (result.equals(FHAESResult.BINARY_MATRIX_01)) {

            if (this.bin01Model == null) {
                clearTable();
                return;
            }

            table.setModel(bin01Model);
            // table.setSortOrder(0, SortOrder.ASCENDING);
            setDefaultTableAlignment(SwingConstants.RIGHT);
        }

        else if (result.equals(FHAESResult.BINARY_MATRIX_10)) {

            if (this.bin10Model == null) {
                clearTable();
                return;
            }

            table.setModel(bin10Model);
            // table.setSortOrder(0, SortOrder.ASCENDING);
            setDefaultTableAlignment(SwingConstants.RIGHT);
        } else if (result.equals(FHAESResult.BINARY_MATRIX_11)) {

            if (this.bin11Model == null) {
                clearTable();
                return;
            }

            table.setModel(bin11Model);
            // table.setSortOrder(0, SortOrder.ASCENDING);
            setDefaultTableAlignment(SwingConstants.RIGHT);
        } else if (result.equals(FHAESResult.BINARY_MATRIX_SUM)) {

            if (this.binSumModel == null) {
                clearTable();
                return;
            }
            table.setModel(binSumModel);
            setDefaultTableAlignment(SwingConstants.RIGHT);
        } else if (result.equals(FHAESResult.JACCARD_SIMILARITY_MATRIX)) {

            if (this.SJACModel == null) {
                clearTable();
                return;
            }
            table.setModel(SJACModel);
            setDefaultTableAlignment(SwingConstants.RIGHT);
        } else if (result.equals(FHAESResult.COHEN_SIMILARITITY_MATRIX)) {

            if (this.SCOHModel == null) {
                clearTable();
                return;
            }
            table.setModel(SCOHModel);
            setDefaultTableAlignment(SwingConstants.RIGHT);
        } else if (result.equals(FHAESResult.JACCARD_SIMILARITY_MATRIX_D)) {

            if (this.DSJACModel == null) {
                clearTable();
                return;
            }
            table.setModel(DSJACModel);
            setDefaultTableAlignment(SwingConstants.RIGHT);
        } else if (result.equals(FHAESResult.COHEN_SIMILARITITY_MATRIX_D)) {

            if (this.DSCOHModel == null) {
                clearTable();
                return;
            }
            table.setModel(DSCOHModel);
            setDefaultTableAlignment(SwingConstants.RIGHT);
        } else if (result.equals(FHAESResult.BINARY_MATRIX_NTP)) {

            log.debug("doing NTP");
            if (this.NTPModel == null) {
                log.debug("fileNTP is null so clearing table");

                clearTable();
                return;
            }
            table.setModel(NTPModel);
            setDefaultTableAlignment(SwingConstants.RIGHT);
        } else if (result.equals(FHAESResult.BINARY_MATRIX_SITE)) {

            if (this.siteSummaryModel == null) {
                clearTable();
                return;
            }
            table.setModel(siteSummaryModel);
            setDefaultTableAlignment(SwingConstants.RIGHT);
        } else if (result.equals(FHAESResult.BINARY_MATRIX_TREE)) {

            if (this.treeSummaryModel == null) {
                clearTable();
                return;
            }
            table.setModel(treeSummaryModel);
            setDefaultTableAlignment(SwingConstants.RIGHT);
        }

        else if (result.equals(FHAESResult.GENERAL_SUMMARY)) {

            if (this.generalSummaryModel == null) {
                clearTable();
                return;
            }
            table.setModel(generalSummaryModel);
            setDefaultTableAlignment(SwingConstants.RIGHT);
        }

        else if (result.equals(FHAESResult.SINGLE_FILE_SUMMARY)) {

            if (this.singleFileSummaryModel == null) {
                clearTable();
                return;
            }
            table.setModel(singleFileSummaryModel);
            setDefaultTableAlignment(SwingConstants.RIGHT);
        }

        else if (result.equals(FHAESResult.SINGLE_EVENT_SUMMARY)) {

            if (this.singleEventSummaryModel == null) {
                clearTable();
                return;
            }
            table.setModel(singleEventSummaryModel);
            setDefaultTableAlignment(SwingConstants.RIGHT);
            setTableColumnAlignment(SwingConstants.LEFT, 2);
        }

        else {
            log.warn("Unhandled FHAESResult type");
            clearTable();
        }

        table.packAll();

        table.setColumnControlVisible(true);
        table.setAutoCreateRowSorter(true);

    } catch (Exception e) {
        log.debug("Caught exception loading table data");

    } finally {
        log.debug("Clearing cursor");

        table.setCursor(Cursor.getDefaultCursor());
        treeResults.setCursor(Cursor.getDefaultCursor());
    }

}

From source file:org.interreg.docexplore.DocExploreTool.java

@SuppressWarnings("serial")
protected static File askForHome(String text) {
    final File[] file = { null };
    final JDialog dialog = new JDialog((Frame) null, XMLResourceBundle.getBundledString("homeLabel"), true);
    JPanel content = new JPanel(new LooseGridLayout(0, 1, 10, 10, true, false, SwingConstants.CENTER,
            SwingConstants.TOP, true, false));
    content.setBorder(BorderFactory.createEmptyBorder(10, 10, 0, 10));
    JLabel message = new JLabel(text, ImageUtils.getIcon("free-64x64.png"), SwingConstants.LEFT);
    message.setIconTextGap(20);//from ww  w .  j  av  a2 s.  c om
    //message.setFont(Font.decode(Font.SANS_SERIF));
    content.add(message);

    final JPanel pathPanel = new JPanel(new FlowLayout(FlowLayout.CENTER, 10, 10));
    pathPanel.add(new JLabel("<html><b>" + XMLResourceBundle.getBundledString("homeLabel") + ":</b></html>"));
    final JTextField pathField = new JTextField(System.getProperty("user.home") + File.separator + "DocExplore",
            40);
    pathPanel.add(pathField);
    pathPanel.add(new JButton(new AbstractAction(XMLResourceBundle.getBundledString("browseLabel")) {
        JNativeFileDialog nfd = null;

        public void actionPerformed(ActionEvent arg0) {
            if (nfd == null) {
                nfd = new JNativeFileDialog();
                nfd.acceptFiles = false;
                nfd.acceptFolders = true;
                nfd.multipleSelection = false;
                nfd.title = XMLResourceBundle.getBundledString("homeLabel");
            }
            nfd.setCurrentFile(new File(pathField.getText()));
            if (nfd.showOpenDialog())
                pathField.setText(nfd.getSelectedFile().getAbsolutePath());
        }
    }));
    content.add(pathPanel);

    JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.CENTER, 10, 10));
    buttonPanel.add(new JButton(new AbstractAction(XMLResourceBundle.getBundledString("cfgOkLabel")) {
        public void actionPerformed(ActionEvent e) {
            File res = new File(pathField.getText());
            if (res.exists() && !res.isDirectory() || !res.exists() && !res.mkdirs())
                JOptionPane.showMessageDialog(dialog, XMLResourceBundle.getBundledString("homeErrorMessage"),
                        XMLResourceBundle.getBundledString("errorLabel"), JOptionPane.ERROR_MESSAGE);
            else {
                file[0] = res;
                dialog.setVisible(false);
            }
        }
    }));
    buttonPanel.add(new JButton(new AbstractAction(XMLResourceBundle.getBundledString("cfgCancelLabel")) {
        public void actionPerformed(ActionEvent e) {
            dialog.setVisible(false);
        }
    }));
    content.add(buttonPanel);

    dialog.getContentPane().add(content);
    dialog.pack();
    dialog.setResizable(false);
    GuiUtils.centerOnScreen(dialog);
    dialog.setVisible(true);
    return file[0];
}