Search in sources :

Example 56 with JScrollBar

use of javax.swing.JScrollBar in project browsermator by pcalkins.

the class ImportFileThread method ImportNewWindow.

public void ImportNewWindow(Document doc, int MDI_INDEX) {
    int current_number_of_procedures = STAppFrame.BugViewArray.size();
    try {
        NodeList ProcedureList = doc.getElementsByTagName("Procedure");
        for (int i = 0; i < ProcedureList.getLength(); ++i) {
            Element Procedure = (Element) ProcedureList.item(i);
            String ProcType = "Procedure";
            if (Procedure.hasAttribute("Type")) {
                ProcType = Procedure.getAttribute("Type");
            }
            String DataLoopSource = "urllist";
            if (Procedure.hasAttribute("DataLoopSource")) {
                DataLoopSource = Procedure.getAttribute("DataLoopSource");
            }
            if ("Dataloop".equals(ProcType)) {
                String DataFile = "";
                if (Procedure.hasAttribute("DataLoopFile")) {
                    DataFile = Procedure.getAttribute("DataLoopFile");
                    // legacy support...
                    if (DataFile.contains(File.separator)) {
                        DataLoopSource = "file";
                    }
                }
                if ("file".equals(DataLoopSource)) {
                    File DataFile_file = new File(DataFile);
                    STAppData.AddNewDataLoopFile(DataFile_file);
                    STAppFrame.AddNewDataLoopFileView(DataFile_file);
                }
                if ("urllist".equals(DataLoopSource)) {
                    String[] parts = DataFile.split("-");
                    String leftpart = parts[0];
                    String rightpart = "0";
                    if (parts.length > 1) {
                        rightpart = parts[1];
                    }
                    if (!"".equals(leftpart)) {
                        leftpart = Integer.toString(current_number_of_procedures + Integer.parseInt(leftpart));
                    } else {
                        leftpart = "0";
                    }
                    String combinedDataFile = leftpart + "-" + rightpart;
                    STAppData.AddNewDataLoopURLList(combinedDataFile);
                    STAppFrame.AddNewDataLoopURLListView(combinedDataFile);
                }
            } else {
                STAppData.AddNewBug();
                STAppFrame.AddNewBugView();
            }
            int last_added_bug_index = STAppFrame.BugViewArray.size() - 1;
            ProcedureView newbugview = STAppFrame.BugViewArray.get(last_added_bug_index);
            newbugview.populateJComboBoxStoredArrayLists(STAppData.VarLists);
            Procedure newbug = STAppData.BugArray.get(last_added_bug_index);
            mainAppController.AddNewHandlers(STAppFrame, STAppData, newbugview, newbug);
            if (Procedure.hasAttribute("Random")) {
                String stRand = Procedure.getAttribute("Random");
                Boolean Rand = false;
                if (stRand.equals("true")) {
                    Rand = true;
                }
                newbug.setRandom(Rand);
                newbugview.setRandom(Rand);
            }
            if (Procedure.hasAttribute("Limit")) {
                int limit = Integer.parseInt(Procedure.getAttribute("Limit"));
                newbug.setLimit(limit);
                newbugview.setLimit(limit);
            }
            String BugTitle = "";
            if (Procedure.hasAttribute("Title")) {
                BugTitle = Procedure.getAttribute("Title");
            }
            newbug.setBugTitle(BugTitle);
            newbugview.setBugTitle(BugTitle);
            String BugURL = "";
            if (Procedure.hasAttribute("URL")) {
                BugURL = Procedure.getAttribute("URL");
            }
            newbug.setBugURL(BugURL);
            // needed?
            // String stPass = Procedure.getAttribute("Pass");
            // Boolean Pass = false;
            // if (stPass.equals("true"))
            // {
            // Pass = true;
            // }
            // STAppData.BugArray.get(i).setPass(Pass);
            NodeList ActionsList = Procedure.getElementsByTagName("Action");
            for (int j = 0; j < ActionsList.getLength(); j++) {
                Element Action = (Element) ActionsList.item(j);
                NodeList ActionNodes = Action.getChildNodes();
                String thisActionNodeName = "none";
                String thisActionNodeValue = "none";
                String Variable1 = "";
                String Variable2 = "";
                String LOCKED = "false";
                String BoolVal1 = "false";
                String BoolVal2 = "false";
                String TimeOfTest;
                String ActionType = "none";
                String ActionIndex;
                String ActionPass;
                String Password = "";
                Boolean RealBoolVal1 = false;
                Boolean RealBoolVal2 = false;
                Boolean boolLOCKED = false;
                for (int k = 0; k < ActionNodes.getLength(); k++) {
                    thisActionNodeName = ActionNodes.item(k).getNodeName();
                    thisActionNodeValue = ActionNodes.item(k).getTextContent();
                    switch(thisActionNodeName) {
                        case "Pass":
                            ActionPass = thisActionNodeValue;
                            break;
                        case "ActionIndex":
                            ActionIndex = thisActionNodeValue;
                            break;
                        case "Type":
                            ActionType = thisActionNodeValue;
                            break;
                        case "Variable1":
                            Variable1 = thisActionNodeValue;
                            break;
                        case "Variable2":
                            Variable2 = thisActionNodeValue;
                            break;
                        case "BoolVal1":
                            BoolVal1 = thisActionNodeValue;
                            if (BoolVal1.equals("true")) {
                                RealBoolVal1 = true;
                            }
                            break;
                        case "BoolVal2":
                            BoolVal2 = thisActionNodeValue;
                            if (BoolVal2.equals("true")) {
                                RealBoolVal2 = true;
                            }
                            break;
                        case "LOCKED":
                            LOCKED = thisActionNodeValue;
                            if (LOCKED.equals("true")) {
                                boolLOCKED = true;
                            }
                            break;
                        case "TimeOfTest":
                            TimeOfTest = thisActionNodeValue;
                            break;
                    }
                }
                if (ActionType.contains("Password")) {
                    try {
                        Password = Protector.decrypt(Variable2);
                        Variable2 = Password;
                    } catch (Exception e) {
                    // System.out.println("Load/decrypt error: " + e.toString());
                    }
                }
                ActionsMaster NewActionsMaster = new ActionsMaster();
                HashMap<String, Action> thisActionHashMap = NewActionsMaster.ActionHashMap;
                HashMap<String, ActionView> thisActionViewHashMap = NewActionsMaster.ActionViewHashMap;
                HashMap<String, Action> thisPassFailActionHashMap = NewActionsMaster.PassFailActionHashMap;
                HashMap<String, ActionView> thisPassFailActionViewHashMap = NewActionsMaster.PassFailActionViewHashMap;
                if (thisActionHashMap.containsKey(ActionType)) {
                    Action thisActionToAdd = (Action) thisActionHashMap.get(ActionType);
                    ActionView thisActionViewToAdd = (ActionView) thisActionViewHashMap.get(ActionType);
                    thisActionToAdd.SetVars(Variable1, Variable2, Password, RealBoolVal1, RealBoolVal2, boolLOCKED);
                    thisActionViewToAdd.SetVars(Variable1, Variable2, Password, RealBoolVal1, RealBoolVal2, boolLOCKED);
                    thisActionViewToAdd.AddListeners(thisActionToAdd, MDIViewClasses.get(MDI_INDEX), MDIDataClasses.get(MDI_INDEX), newbug, newbugview);
                    thisActionViewToAdd.AddLoopListeners(thisActionToAdd, MDIViewClasses.get(MDI_INDEX), MDIDataClasses.get(MDI_INDEX), newbug, newbugview);
                    MDIViewClasses.get(MDI_INDEX).AddActionViewToArray(thisActionViewToAdd, newbugview);
                    MDIDataClasses.get(MDI_INDEX).AddActionToArray(thisActionToAdd, newbug);
                }
                if (thisPassFailActionHashMap.containsKey(ActionType)) {
                    Action thisActionToAdd = (Action) thisPassFailActionHashMap.get(ActionType);
                    ActionView thisActionViewToAdd = (ActionView) thisPassFailActionViewHashMap.get(ActionType);
                    thisActionToAdd.SetVars(Variable1, Variable2, Password, RealBoolVal1, RealBoolVal2, boolLOCKED);
                    thisActionViewToAdd.SetVars(Variable1, Variable2, Password, RealBoolVal1, RealBoolVal2, boolLOCKED);
                    thisActionViewToAdd.AddListeners(thisActionToAdd, MDIViewClasses.get(MDI_INDEX), MDIDataClasses.get(MDI_INDEX), newbug, newbugview);
                    thisActionViewToAdd.AddLoopListeners(thisActionToAdd, MDIViewClasses.get(MDI_INDEX), MDIDataClasses.get(MDI_INDEX), newbug, newbugview);
                    MDIViewClasses.get(MDI_INDEX).AddActionViewToArray(thisActionViewToAdd, newbugview);
                    MDIDataClasses.get(MDI_INDEX).AddActionToArray(thisActionToAdd, newbug);
                }
            // MDIClasses.get(MDI_INDEX).UpdateDisplay();
            }
        }
    } catch (Exception e) {
        System.out.println("Exception parsing procedure node" + e.toString());
    }
    STAppFrame.UpdateDisplay();
    JScrollBar vertical = STAppFrame.MainScrollPane.getVerticalScrollBar();
    vertical.setValue(vertical.getMaximum());
}
Also used : NodeList(org.w3c.dom.NodeList) Element(org.w3c.dom.Element) IOException(java.io.IOException) ParserConfigurationException(javax.xml.parsers.ParserConfigurationException) SAXException(org.xml.sax.SAXException) JScrollBar(javax.swing.JScrollBar) File(java.io.File)

Example 57 with JScrollBar

use of javax.swing.JScrollBar in project opennars by opennars.

the class VerticalPanel method scrollBottom.

public void scrollBottom() {
    JScrollBar vertical = scrollPane.getVerticalScrollBar();
    vertical.setValue(vertical.getMaximum());
}
Also used : JScrollBar(javax.swing.JScrollBar)

Example 58 with JScrollBar

use of javax.swing.JScrollBar in project logisim-evolution by reds-heig.

the class SmartScroller method checkScrollBar.

/*
	 * Analyze every adjustment event to determine when the viewport needs to be
	 * repositioned.
	 */
private void checkScrollBar(AdjustmentEvent e) {
    // The scroll bar listModel contains information needed to determine
    // whether the viewport should be repositioned or not.
    JScrollBar scrollBar = (JScrollBar) e.getSource();
    BoundedRangeModel listModel = scrollBar.getModel();
    int value = listModel.getValue();
    int extent = listModel.getExtent();
    int maximum = listModel.getMaximum();
    boolean valueChanged = previousValue != value;
    boolean maximumChanged = previousMaximum != maximum;
    if (valueChanged && !maximumChanged) {
        if (viewportPosition == START)
            adjustScrollBar = value != 0;
        else
            adjustScrollBar = value + extent >= maximum;
    }
    if (adjustScrollBar && viewportPosition == END) {
        // Scroll the viewport to the end.
        scrollBar.removeAdjustmentListener(this);
        value = maximum - extent;
        scrollBar.setValue(value);
        scrollBar.addAdjustmentListener(this);
    }
    if (adjustScrollBar && viewportPosition == START) {
        // Keep the viewport at the same relative viewportPosition
        scrollBar.removeAdjustmentListener(this);
        value = value + maximum - previousMaximum;
        scrollBar.setValue(value);
        scrollBar.addAdjustmentListener(this);
    }
    previousValue = value;
    previousMaximum = maximum;
}
Also used : BoundedRangeModel(javax.swing.BoundedRangeModel) JScrollBar(javax.swing.JScrollBar)

Example 59 with JScrollBar

use of javax.swing.JScrollBar in project mc-dev by Bukkit.

the class ServerGUI method a.

public void a(JTextArea jtextarea, JScrollPane jscrollpane, String s) {
    if (!SwingUtilities.isEventDispatchThread()) {
        SwingUtilities.invokeLater(new ServerGuiInvokeRunnable(this, jtextarea, jscrollpane, s));
    } else {
        Document document = jtextarea.getDocument();
        JScrollBar jscrollbar = jscrollpane.getVerticalScrollBar();
        boolean flag = false;
        if (jscrollpane.getViewport().getView() == jtextarea) {
            flag = (double) jscrollbar.getValue() + jscrollbar.getSize().getHeight() + (double) (a.getSize() * 4) > (double) jscrollbar.getMaximum();
        }
        try {
            document.insertString(document.getLength(), s, (AttributeSet) null);
        } catch (BadLocationException badlocationexception) {
            ;
        }
        if (flag) {
            jscrollbar.setValue(Integer.MAX_VALUE);
        }
    }
}
Also used : Document(javax.swing.text.Document) BadLocationException(javax.swing.text.BadLocationException) JScrollBar(javax.swing.JScrollBar)

Example 60 with JScrollBar

use of javax.swing.JScrollBar in project GCViewer by chewiebug.

the class GCDocument method setWatched.

public void setWatched(boolean watched) {
    this.watched = watched;
    final JScrollBar horizontalScrollBar = ((ModelChartImpl) getLastMaximizedChartPanelView().getModelChart()).getHorizontalScrollBar();
    if (watched) {
        horizontalScrollBar.setValue(horizontalScrollBar.getMaximum());
    }
    horizontalScrollBar.setEnabled(!watched);
}
Also used : JScrollBar(javax.swing.JScrollBar)

Aggregations

JScrollBar (javax.swing.JScrollBar)60 Dimension (java.awt.Dimension)12 Point (java.awt.Point)12 JScrollPane (javax.swing.JScrollPane)10 JLabel (javax.swing.JLabel)7 JPanel (javax.swing.JPanel)6 Component (java.awt.Component)5 JTabbedPane (javax.swing.JTabbedPane)5 JTextArea (javax.swing.JTextArea)5 GridBagConstraints (java.awt.GridBagConstraints)4 Insets (java.awt.Insets)4 ActionEvent (java.awt.event.ActionEvent)4 JPopupMenu (javax.swing.JPopupMenu)4 JViewport (javax.swing.JViewport)4 Color (java.awt.Color)3 GridBagLayout (java.awt.GridBagLayout)3 ActionListener (java.awt.event.ActionListener)3 AdjustmentEvent (java.awt.event.AdjustmentEvent)3 AdjustmentListener (java.awt.event.AdjustmentListener)3 IOException (java.io.IOException)3