def __init__(self): TrafficMod.__init__(self) self.setLayout(BorderLayout()) settings_panel = JPanel() # settings_panel.setBorder(LineBorder(Color.RED)) layout = GroupLayout(settings_panel) layout.setAutoCreateGaps(True) layout.setAutoCreateContainerGaps(True) settings_panel.setLayout(layout) self.add(settings_panel) # Horizontal group horizontal = layout.createParallelGroup() layout.setHorizontalGroup( layout.createSequentialGroup().addGroup(horizontal)) self.horizontal_layout = horizontal # Vertical group vertical = layout.createSequentialGroup() layout.setVerticalGroup(vertical) self.vertical_layout = vertical # Main title, label only main_title = JLabel(self.title) main_title.setFont(get_title_font(main_title)) horizontal.addGroup( layout.createSequentialGroup().addComponent(main_title)) vertical.addGroup( layout.createParallelGroup( GroupLayout.Alignment.BASELINE).addComponent(main_title)) # Profile name name_lbl = JLabel("Profile Name") name_lbl.setToolTipText("The name of this profile") horizontal.addGroup( layout.createSequentialGroup().addComponent(name_lbl).addComponent( self.name_textfield)) vertical.addGroup( layout.createParallelGroup( GroupLayout.Alignment.BASELINE).addComponent( name_lbl).addComponent(self.name_textfield)) # Profile description descr_lbl = JLabel("Description") horizontal.addGroup(layout.createSequentialGroup().addComponent( descr_lbl).addComponent(self.descr_textarea)) vertical.addGroup( layout.createParallelGroup( GroupLayout.Alignment.BASELINE).addComponent( descr_lbl).addComponent(self.descr_textarea)) layout.linkSize(SwingConstants.HORIZONTAL, name_lbl, descr_lbl)
def __init__(self): TrafficMod.__init__(self) self.setLayout(FlowLayout(FlowLayout.LEADING)) settings_panel = JPanel() layout = GroupLayout(settings_panel) layout.setAutoCreateGaps(True) layout.setAutoCreateContainerGaps(True) settings_panel.setLayout(layout) self.add(settings_panel) # Horizontal group horizontal = layout.createParallelGroup() layout.setHorizontalGroup( layout.createSequentialGroup().addGroup(horizontal)) # Vertical group vertical = layout.createSequentialGroup() layout.setVerticalGroup(vertical) # Main title, label only main_title = JLabel(self.title) main_title.setFont(Font(main_title.getFont().getName(), Font.BOLD, 14)) horizontal.addGroup( layout.createSequentialGroup().addComponent(main_title)) vertical.addGroup( layout.createParallelGroup( GroupLayout.Alignment.BASELINE).addComponent(main_title)) # Duplicate percentage percent_lbl = JLabel("Duplicate %") horizontal.addGroup(layout.createSequentialGroup().addComponent( percent_lbl).addComponent(self.duplicate_percent)) vertical.addGroup( layout.createParallelGroup( GroupLayout.Alignment.BASELINE).addComponent( percent_lbl).addComponent(self.duplicate_percent)) # Duplicate percentage correlation corr_lbl = JLabel("Correlation %") horizontal.addGroup( layout.createSequentialGroup().addComponent(corr_lbl).addComponent( self.duplicate_percent_correlation)) vertical.addGroup( layout.createParallelGroup( GroupLayout.Alignment.BASELINE).addComponent( corr_lbl).addComponent(self.duplicate_percent_correlation)) layout.linkSize(SwingConstants.HORIZONTAL, corr_lbl, percent_lbl)
def __init__(self, pP): ''' Constructor ''' self.pP = pP self.annotationType = self.pP.getAnnotationType() self.setTitle("Random Picture Picker") #annotation Panel annoPanel = JPanel() annoPanel.setBorder(BorderFactory.createTitledBorder("Annotations")) annoPLayout = GroupLayout(annoPanel) annoPanel.setLayout(annoPLayout) annoPLayout.setAutoCreateContainerGaps(True) annoPLayout.setAutoCreateGaps(True) # dynamic creation of annotation panel # yesNoIgnore, int, number, list if len(self.pP.getAnnotationType()) == 1: self.annoField = JTextField("", 16) annoPLayout.setHorizontalGroup(annoPLayout.createParallelGroup().addComponent(self.annoField)) annoPLayout.setVerticalGroup(annoPLayout.createSequentialGroup().addComponent(self.annoField)) elif len(self.pP.getAnnotationType()) > 1: choices = pP.getAnnotationType() print "choices", choices choiceBtns = [] self.annoField = ButtonGroup() for c in choices: Btn = JRadioButton(c, actionCommand=c) self.annoField.add(Btn) choiceBtns.append(Btn) h = annoPLayout.createParallelGroup() for b in choiceBtns: h.addComponent(b) annoPLayout.setHorizontalGroup(h) v = annoPLayout.createSequentialGroup() for b in choiceBtns: v.addComponent(b) annoPLayout.setVerticalGroup(v) # Control Panel ctrlPanel = JPanel() ctrlPLayout = GroupLayout(ctrlPanel, autoCreateContainerGaps=True, autoCreateGaps=True) ctrlPanel.setLayout(ctrlPLayout) nextImgButton = JButton("Next >", actionPerformed=self.nextPicture) prevImgButton = JButton("< Prev", actionPerformed=self.pP.prevPicture) quitButton = JButton("Quit", actionPerformed=self.exit) ctrlPLayout.setHorizontalGroup(ctrlPLayout.createParallelGroup(GroupLayout.Alignment.CENTER) .addGroup(ctrlPLayout.createSequentialGroup() .addComponent(prevImgButton) .addComponent(nextImgButton)) .addComponent(quitButton)) ctrlPLayout.setVerticalGroup(ctrlPLayout.createSequentialGroup() .addGroup(ctrlPLayout.createParallelGroup() .addComponent(prevImgButton) .addComponent(nextImgButton)) .addComponent(quitButton)) ctrlPLayout.linkSize(SwingConstants.HORIZONTAL, quitButton) statusPanel = JPanel() # contains status information: progress bar self.progressBar = JProgressBar() self.progressBar.setStringPainted(True) self.progressBar.setValue(0) statusPanel.add(self.progressBar) #MainLayout mainLayout = GroupLayout(self.getContentPane()) self.getContentPane().setLayout(mainLayout) mainLayout.setHorizontalGroup(mainLayout.createParallelGroup(GroupLayout.Alignment.CENTER) .addComponent(annoPanel) .addComponent(ctrlPanel) .addComponent(statusPanel) ) mainLayout.setVerticalGroup(mainLayout.createSequentialGroup() .addComponent(annoPanel) .addComponent(ctrlPanel) .addComponent(statusPanel) ) mainLayout.linkSize(SwingConstants.HORIZONTAL, annoPanel, ctrlPanel, statusPanel) self.pack() self.setVisible(True) self.pP.nextPicture()
def __init__(self, callbacks, table=None): self.callbacks = callbacks self.jScrollPane1 = JScrollPane() self.jPanel1 = JPanel() self.labelName = JLabel("Name") self.textName = JTextField() self.labelSeverity = JLabel("Severity") self.textSeverity = JTextField() self.labelHost = JLabel("Host") self.labelPath = JLabel("Path") self.textHost = JTextField() self.textPath = JTextField() self.tabIssue = JTabbedPane() self.textAreaDescription = JTextArea() self.textAreaRemediation = JTextArea() # JScrollPanes to hold the two jTextAreas # put the textareas in JScrollPanes self.jsPaneDescription = JScrollPane(self.textAreaDescription) self.jsPaneRemediation = JScrollPane(self.textAreaRemediation) self.panelRequest = self.callbacks.createMessageEditor(None, False) self.panelResponse = self.callbacks.createMessageEditor(None, False) self.loadPanel(self.defaultIssue) # buttons self.buttonNewIssue = JButton("New Issue", actionPerformed=self.newIssueAction) self.buttonDeleteIssue = JButton( "Delete Issue", actionPerformed=self.deleteIssueAction) self.buttonImport = JButton("Import", actionPerformed=self.importAction) self.buttonExport = JButton("Export", actionPerformed=self.exportAction) if table is not None: self.tableIssue = table else: from IssueTable import IssueTable self.tableIssue = IssueTable() # wrap the table in a scrollpane self.jScrollPane1.setViewportView(self.tableIssue) # top panel containing the table from java.awt import Color self.jPanel1.setBorder(BorderFactory.createLineBorder(Color(0, 0, 0))) # create the labels and textfields self.textName.editable = False self.textName.setBackground(Color.LIGHT_GRAY) self.textSeverity.editable = False self.textSeverity.setBackground(Color.LIGHT_GRAY) self.textHost.editable = False self.textHost.setBackground(Color.LIGHT_GRAY) self.textPath.editable = False self.textPath.setBackground(Color.LIGHT_GRAY) # description textarea self.textAreaDescription.editable = False self.textAreaDescription.setLineWrap(True) self.textAreaDescription.setWrapStyleWord(True) self.tabIssue.addTab("Description", self.jsPaneDescription) # remediation textarea self.textAreaRemediation.editable = False self.textAreaRemediation.setLineWrap(True) self.textAreaRemediation.setWrapStyleWord(True) self.tabIssue.addTab("Remediation", self.jsPaneRemediation) # request tab self.panelRequest.setMessage("", True) self.tabIssue.addTab("Request", self.panelRequest.getComponent()) # response tab self.panelResponse.setMessage("", False) self.tabIssue.addTab("Response", self.panelResponse.getComponent()) # from java.lang import Short # jpanel1 is the bottom panel jPanel1Layout = GroupLayout(self.jPanel1) self.jPanel1.setLayout(jPanel1Layout) jPanel1Layout.setHorizontalGroup( # GroupLayout.Alignment.CENTER centers the group, in this case it # centers the buttons jPanel1Layout.createParallelGroup( GroupLayout.Alignment.CENTER ).addGroup(jPanel1Layout.createSequentialGroup().addContainerGap( ).addGroup( jPanel1Layout.createParallelGroup( GroupLayout.Alignment.LEADING). addGroup(jPanel1Layout.createSequentialGroup().addGroup( jPanel1Layout.createParallelGroup( GroupLayout.Alignment.TRAILING).addComponent( self.labelHost).addComponent(self.labelName) ).addPreferredGap( LayoutStyle.ComponentPlacement.UNRELATED).addGroup( jPanel1Layout.createParallelGroup( GroupLayout.Alignment.LEADING).addGroup( jPanel1Layout.createSequentialGroup( ).addComponent(self.textName).addPreferredGap( LayoutStyle.ComponentPlacement.UNRELATED). addComponent( self.labelSeverity).addPreferredGap( LayoutStyle.ComponentPlacement. RELATED).addComponent( self.textSeverity, GroupLayout.PREFERRED_SIZE, 186, GroupLayout.PREFERRED_SIZE)). addGroup( jPanel1Layout.createSequentialGroup().addComponent( self.textHost, GroupLayout.PREFERRED_SIZE, 330, GroupLayout.PREFERRED_SIZE).addPreferredGap( LayoutStyle.ComponentPlacement.RELATED ).addComponent(self.labelPath).addPreferredGap( LayoutStyle.ComponentPlacement.RELATED). addComponent(self.textPath)))).addComponent( self.tabIssue)).addContainerGap() ).addGroup( jPanel1Layout.createSequentialGroup().addComponent( self.buttonNewIssue).addComponent( self.buttonDeleteIssue).addComponent( self.buttonImport).addComponent( self.buttonExport))) # link size of buttons from javax.swing import SwingConstants jPanel1Layout.linkSize(SwingConstants.HORIZONTAL, [ self.buttonDeleteIssue, self.buttonExport, self.buttonImport, self.buttonNewIssue ]) jPanel1Layout.setVerticalGroup(jPanel1Layout.createParallelGroup( ).addGroup( jPanel1Layout.createSequentialGroup().addContainerGap().addGroup( jPanel1Layout.createParallelGroup( GroupLayout.Alignment.BASELINE).addComponent( self.labelName).addComponent( self.textName, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE).addComponent( self.labelSeverity).addComponent( self.textSeverity, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) ).addPreferredGap(LayoutStyle.ComponentPlacement.RELATED).addGroup( jPanel1Layout.createParallelGroup( GroupLayout.Alignment.BASELINE).addComponent( self.textHost, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE).addComponent( self.labelPath).addComponent( self.textPath, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE).addComponent( self.labelHost)).addPreferredGap( LayoutStyle.ComponentPlacement.RELATED) .addComponent(self.tabIssue).addPreferredGap( LayoutStyle.ComponentPlacement.RELATED).addGroup( jPanel1Layout.createParallelGroup().addComponent( self.buttonNewIssue).addComponent( self.buttonDeleteIssue).addComponent( self.buttonImport).addComponent( self.buttonExport)).addContainerGap())) # create the main panel self.panel = JSplitPane(JSplitPane.VERTICAL_SPLIT) # set the top component self.panel.leftComponent = self.jScrollPane1 self.panel.rightComponent = self.jPanel1 self.panel.setDividerLocation(150)
def __init__(self): self.listModel = DefaultListModel() self.cbTitle = JLabel("Out-of-band Payloads") self.cbTitle.setFont(self.cbTitle.getFont().deriveFont(14.0)) self.cbTitle.setFont(self.cbTitle.getFont().deriveFont(Font.BOLD)) self.cbSubTitle = JLabel( "Add payloads to active scanner that interact " "with out-of-band services (e.g., XSSHunter)") self.cbSubTitle.setFont(self.cbSubTitle.getFont().deriveFont(12.0)) self.cbList = JList(self.listModel) self.cbList.setCellRenderer(ListRenderer()) self.cbList.setVisibleRowCount(10) self.listScrollPane = JScrollPane(self.cbList) self.cbText = JTextField(actionPerformed=self.add_element) self.cbRemoveButton = JButton("Remove", actionPerformed=self.remove_element) self.cbLoadButton = JButton("Load...", actionPerformed=self.add_file) self.cbPasteButton = JButton("Paste", actionPerformed=self.paste_elements) self.cbClearButton = JButton("Clear", actionPerformed=self.clear_elements) self.cbAddButton = JButton("Add", actionPerformed=self.add_element) self.cbDropDownLabel = JLabel("Payload Encoding: ") self.cbDropDown = JComboBox() self.cbDropDown.addItem("Non URL Encoded") self.cbDropDown.addItem("URL Encoded") self.cbDropDown.addItem("Both (two requests per payload)") self.grpOOB = JPanel() grpLayout = GroupLayout(self.grpOOB) self.grpOOB.setLayout(grpLayout) grpLayout.linkSize(SwingConstants.HORIZONTAL, self.cbRemoveButton, self.cbLoadButton, self.cbPasteButton, self.cbClearButton, self.cbAddButton) grpLayout.setAutoCreateGaps(True) grpLayout.setAutoCreateContainerGaps(True) grpLayout.setHorizontalGroup( grpLayout.createSequentialGroup().addGroup( grpLayout.createParallelGroup().addComponent( self.cbTitle).addGroup( grpLayout.createParallelGroup().addComponent( self.cbRemoveButton).addComponent( self.cbLoadButton).addComponent( self.cbPasteButton).addComponent( self.cbClearButton)).addComponent( self.cbAddButton). addComponent(self.cbDropDownLabel)).addGroup( grpLayout.createParallelGroup().addComponent( self.cbSubTitle).addComponent( self.listScrollPane).addComponent( self.cbText).addComponent(self.cbDropDown))) grpLayout.setVerticalGroup(grpLayout.createSequentialGroup().addGroup( grpLayout.createParallelGroup().addComponent(self.cbTitle) ).addGroup(grpLayout.createParallelGroup().addComponent( self.cbSubTitle)).addGroup( grpLayout.createParallelGroup().addGroup( grpLayout.createSequentialGroup().addComponent( self.cbPasteButton).addComponent( self.cbLoadButton).addComponent( self.cbRemoveButton).addComponent( self.cbClearButton)).addComponent( self.listScrollPane) ).addGroup(grpLayout.createParallelGroup().addComponent( self.cbAddButton).addComponent(self.cbText)).addGroup( grpLayout.createParallelGroup().addComponent( self.cbDropDownLabel).addComponent(self.cbDropDown))) # Tab Layout self.tab = JPanel() tabLayout = GroupLayout(self.tab) self.tab.setLayout(tabLayout) tabLayout.setAutoCreateGaps(True) tabLayout.setAutoCreateContainerGaps(True) tabLayout.setHorizontalGroup( tabLayout.createSequentialGroup().addGroup( tabLayout.createParallelGroup().addComponent( self.grpOOB, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE))) tabLayout.setVerticalGroup(tabLayout.createSequentialGroup().addGroup( tabLayout.createParallelGroup().addComponent( self.grpOOB, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE)))
class BurpExtender(IBurpExtender, ITab, IContextMenuFactory, DocumentListener, ChangeListener): # # implement IBurpExtender # def registerExtenderCallbacks(self, callbacks): print "PhantomJS RIA Crawler extension" print "Nikolay Matyunin @autorak <*****@*****.**>" # keep a reference to our callbacks object and helpers object self._callbacks = callbacks self._helpers = callbacks.getHelpers() # extension name callbacks.setExtensionName("Phantom RIA Crawler") # Create Tab UI components self._jPanel = JPanel() self._jPanel.setBorder(BorderFactory.createEmptyBorder(5,5,5,5)); _titleLabel = JLabel("Phantom RIA Crawler", SwingConstants.LEFT) _titleLabelFont = _titleLabel.font _titleLabelFont = _titleLabelFont.deriveFont(Font.BOLD, 12); _titleLabel.setFont(_titleLabelFont); _titleLabel.setForeground(Color(230, 142, 11)) self._addressTextField = JTextField('') self._addressTextField.setColumns(50) _addressTextLabel = JLabel("Target URL:", SwingConstants.RIGHT) self._addressTextField.getDocument().addDocumentListener(self) self._phantomJsPathField = JTextField('phantomjs') # TODO: set permanent config value self._phantomJsPathField.setColumns(50) _phantomJsPathLabel = JLabel("PhantomJS path:", SwingConstants.RIGHT) self._startButton = JToggleButton('Start', actionPerformed=self.startToggled) self._startButton.setEnabled(False) _requestsMadeLabel = JLabel("DEPs found:", SwingConstants.RIGHT) self._requestsMadeInfo = JLabel("", SwingConstants.LEFT) _statesFoundLabel = JLabel("States found:", SwingConstants.RIGHT) self._statesFoundInfo = JLabel("", SwingConstants.LEFT) _separator = JSeparator(SwingConstants.HORIZONTAL) _configLabel = JLabel("Crawling configuration:") self._configButton = JButton("Load config", actionPerformed=self.loadConfigClicked) self._configFile = "" _listenersLabel= JLabel("Burp proxy listener:", SwingConstants.RIGHT) self._listenersCombo = JComboBox() self._configTimer = Timer(5000, None) self._configTimer.actionPerformed = self._configUpdated self._configTimer.stop() self._configUpdated(None) self._commandClient = CommandClient(self) # Layout management self._groupLayout = GroupLayout(self._jPanel) self._jPanel.setLayout(self._groupLayout) self._groupLayout.setAutoCreateGaps(True) self._groupLayout.setAutoCreateContainerGaps(True) self._groupLayout.setHorizontalGroup(self._groupLayout.createParallelGroup() .addComponent(_titleLabel) .addGroup(self._groupLayout.createSequentialGroup() .addComponent(_addressTextLabel) .addGroup(self._groupLayout.createParallelGroup() .addComponent(self._addressTextField, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE) .addGroup(self._groupLayout.createSequentialGroup() .addComponent(_requestsMadeLabel) .addComponent(self._requestsMadeInfo)) .addGroup(self._groupLayout.createSequentialGroup() .addComponent(_statesFoundLabel) .addComponent(self._statesFoundInfo))) .addComponent(self._startButton)) .addComponent(_separator) .addGroup(self._groupLayout.createSequentialGroup() .addComponent(_configLabel) .addComponent(self._configButton)) .addGroup(self._groupLayout.createSequentialGroup() .addComponent(_phantomJsPathLabel) .addComponent(self._phantomJsPathField, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE)) .addGroup(self._groupLayout.createSequentialGroup() .addComponent(_listenersLabel) .addComponent(self._listenersCombo, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE)) ) self._groupLayout.setVerticalGroup(self._groupLayout.createSequentialGroup() .addComponent(_titleLabel) .addGroup(self._groupLayout.createParallelGroup(GroupLayout.Alignment.BASELINE) .addComponent(_addressTextLabel) .addComponent(self._addressTextField) .addComponent(self._startButton)) .addGroup(self._groupLayout.createParallelGroup(GroupLayout.Alignment.BASELINE) .addComponent(_requestsMadeLabel) .addComponent(self._requestsMadeInfo)) .addGroup(self._groupLayout.createParallelGroup(GroupLayout.Alignment.BASELINE) .addComponent(_statesFoundLabel) .addComponent(self._statesFoundInfo)) .addComponent(_separator, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) .addGroup(self._groupLayout.createParallelGroup(GroupLayout.Alignment.BASELINE) .addComponent(_configLabel) .addComponent(self._configButton)) .addGroup(self._groupLayout.createParallelGroup(GroupLayout.Alignment.BASELINE) .addComponent(_phantomJsPathLabel) .addComponent(self._phantomJsPathField)) .addGroup(self._groupLayout.createParallelGroup(GroupLayout.Alignment.BASELINE) .addComponent(_listenersLabel) .addComponent(self._listenersCombo)) ) self._groupLayout.linkSize(SwingConstants.HORIZONTAL, _configLabel, _phantomJsPathLabel); self._groupLayout.linkSize(SwingConstants.HORIZONTAL, _configLabel, _listenersLabel); self._groupLayout.linkSize(SwingConstants.HORIZONTAL, _statesFoundLabel, _requestsMadeLabel); # context menu data self._contextMenuData = None; self._running = False; # register callbacks callbacks.customizeUiComponent(self._jPanel) callbacks.registerContextMenuFactory(self) callbacks.addSuiteTab(self) return # # implement ITab and Tab ChangeListener # def getTabCaption(self): return "Phantom RIA Crawler" def getUiComponent(self): return self._jPanel def stateChanged(self, ev): self._configUpdated() def _configUpdated(self, ev): config = self._callbacks.saveConfig() # update proxy listeners index = 0 listeners = DefaultComboBoxModel() while (("proxy.listener" + str(index)) in config): listenerItem = config["proxy.listener" + str(index)] listenerItems = listenerItem.split(".") if (listenerItems[0] == "1"): address = ".".join(listenerItems[2][1:].split("|")) if (len(address) == 0): address = "127.0.0.1" listeners.addElement(address + " : " + listenerItems[1]) index = index + 1 self._listenersCombo.setModel(listeners) return; # # implement button actions # def startToggled(self, ev): if (self._startButton.getModel().isSelected()): try: os.chdir(sys.path[0] + os.sep + "riacrawler" + os.sep + "scripts") except Exception as e: print >> sys.stderr, "RIA crawler scripts loading error", "I/O error({0}): {1}".format(e.errno, e.strerror) self._startButton.setSelected(False) return phantomJsPath = self._phantomJsPathField.text target = self._addressTextField.text config = "crawler.config" if (self._configFile): config = self._configFile listenerAddress = self._listenersCombo.getSelectedItem().replace(" ", "") p = Popen("{0} --proxy={3} main.js --target={1} --config={2}".format(phantomJsPath, target, config, listenerAddress), shell=True) self._running = True self._requestsMadeInfo.setText("") self._statesFoundInfo.setText("") self._commandClient.startCrawling() else: if (self._running): self._commandClient.stopCrawling() self._running = False def syncCrawlingState(self, result): print "RIA crawling state: ", result self._requestsMadeInfo.setText(str(result["requests_made"])) self._statesFoundInfo.setText(str(result["states_detected"])) if (result["running"] == False): self._commandClient.stopCrawling() self._running = False self._startButton.setSelected(False) def loadConfigClicked(self, ev): openFile = JFileChooser(); openFile.showOpenDialog(None); self._configFile = openFile.getSelectedFile() # # implement DocumentListener for _addressTextField # def removeUpdate(self, ev): self.updateStartButton() def insertUpdate(self, ev): self.updateStartButton() def updateStartButton(self): self._startButton.setEnabled(len(self._addressTextField.text) > 0) # # implement IContextMenuFactory # def createMenuItems(self, contextMenuInvocation): menuItemList = ArrayList() context = contextMenuInvocation.getInvocationContext() if (context == IContextMenuInvocation.CONTEXT_MESSAGE_VIEWER_REQUEST or context == IContextMenuInvocation.CONTEXT_MESSAGE_EDITOR_REQUEST or context == IContextMenuInvocation.CONTEXT_PROXY_HISTORY or context == IContextMenuInvocation.CONTEXT_TARGET_SITE_MAP_TABLE): self._contextMenuData = contextMenuInvocation.getSelectedMessages() menuItemList.add(JMenuItem("Send to Phantom RIA Crawler", actionPerformed = self.menuItemClicked)) return menuItemList def menuItemClicked(self, event): if (self._running == True): self._callbacks.issueAlert("Can't set data to Phantom RIA Crawler: crawling is running already.") return; dataIsSet = False; for message in self._contextMenuData: request = self._helpers.analyzeRequest(message) url = request.getUrl().toString() print url if (url): dataisSet = True; self._addressTextField.setText(url)
def initUI(self): '''Initial UI and Widget creation takes place here! ''' self.setContentPane = JPanel() #self.setDefaultLookAndFeelDecorated(True) # Borders foreground_colour = Color(30,57,68) background_colour = Color(247,246,242) window_background = Color(145,190,210) self.border = BorderFactory.createLoweredBevelBorder() self.border2 = BorderFactory.createLineBorder(foreground_colour, 1, True) # Fonts self.entry_font= Font("Ubuntu Light", Font.BOLD, 20) self.label_font= Font("Ubuntu Light", Font.BOLD, 17) self.btn_font=Font("Ubuntu Light", Font.BOLD, 15) # Layout start layout=GroupLayout(self.getContentPane()) self.getContentPane().setLayout(layout) layout.setAutoCreateGaps(True) layout.setAutoCreateContainerGaps(True) self.setPreferredSize(Dimension(300, 150)) # Create the labels user_label= JLabel(" Username : "******" Server : ", JLabel.LEFT, font=self.label_font) # Colours user_label.setForeground(foreground_colour) server_label.setForeground(foreground_colour) # Create the text entries self.username=JTextField(actionPerformed=self.continueEvent, border=self.border2, font = self.entry_font) self.server=JTextField(actionPerformed=self.continueEvent, border=self.border2, font = self.entry_font) # Colours self.username.setBackground(background_colour) self.server.setBackground(background_colour) self.username.setForeground(foreground_colour) self.server.setForeground(foreground_colour) # Allow editable self.username.setEditable(True) self.server.setEditable(True) # Create the buttons quit_btn=JButton(" Quit! ", actionPerformed=self.closeEvent, border=self.border2, font=self.btn_font) go_btn=JButton(" Go! ", actionPerformed=self.continueEvent, border=self.border2, font=self.btn_font) # Colours quit_btn.setBackground(background_colour) go_btn.setBackground(background_colour) quit_btn.setForeground(foreground_colour) go_btn.setForeground(foreground_colour) # Setting up the horizontal groups parameters layout.setHorizontalGroup(layout.createSequentialGroup() # Left side .addGroup(layout.createParallelGroup(GroupLayout.Alignment.TRAILING) .addComponent(user_label) .addComponent(server_label)) # Right side .addGroup(layout.createParallelGroup(GroupLayout.Alignment.CENTER) .addComponent(self.username) .addComponent(self.server) .addGroup(layout.createSequentialGroup() .addComponent(quit_btn) .addComponent(go_btn))) ) # Setting up Vertical Groups layout.setVerticalGroup(layout.createSequentialGroup() # Top group .addGroup(layout.createParallelGroup(GroupLayout.Alignment.CENTER) .addComponent(user_label) .addComponent(self.username)) # Middle group .addGroup(layout.createParallelGroup(GroupLayout.Alignment.CENTER) .addComponent(server_label) .addComponent(self.server)) # Bottom group .addGroup(layout.createParallelGroup() .addComponent(quit_btn) .addComponent(go_btn)) ) # Finalise the GUI layout.linkSize(SwingConstants.HORIZONTAL, [quit_btn,go_btn]) self.getContentPane().setBackground(window_background) self.pack() self.setTitle('Chat Login') self.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE) self.setLocationRelativeTo(None) self.setVisible(True)
class ChatClient(JFrame): ## Constructor method, receives the variables from the ChatApp class as parameters def __init__(self, name, greeting, tn): '''Constructor, initialises base class & assigns variables ''' # Call to the super method to take care of the base class(es) super(ChatClient, self).__init__() # Assign the relevent variable names self.username=name self.greeting=greeting self.tn = tn self.no_users=[] # Initiate the Threaded function for receiving messages t1=Thread(target=self.recvFunction) # Set to daemon t1.daemon=True t1.start() #Call the main UI uI=self.clientUI() ## Main GUI building function def clientUI(self): '''ClientUI and Widget creation ''' # Colours foreground_colour = Color(30,57,68) background_colour = Color(247,246,242) window_background = Color(145,190,210) # Borders self.border2=BorderFactory.createLineBorder(foreground_colour,1, True) # Fonts self.font= Font("Ubuntu Light", Font.BOLD, 20) self.label_font= Font("Ubuntu Light", Font.BOLD, 17) self.label_2_font= Font( "Ubuntu Light",Font.BOLD, 12) self.btn_font=Font("Ubuntu Light", Font.BOLD, 15) # Set the layout parameters self.client_layout=GroupLayout(self.getContentPane()) self.getContentPane().setLayout(self.client_layout) self.getContentPane().setBackground(window_background) self.client_layout.setAutoCreateGaps(True) self.client_layout.setAutoCreateContainerGaps(True) self.setPreferredSize(Dimension(400, 450)) # Create widgets and assemble the GUI # Main display area self.main_content=JTextPane() self.main_content.setBackground(background_colour) #self.main_content.setForeground(foreground_colour) self.main_content.setEditable(False) # Message entry area self.message=JTextArea( 2,2, border=self.border2, font=self.label_font, keyPressed=self.returnKeyPress) self.message.requestFocusInWindow() self.message.setBackground(background_colour) self.message.setForeground(foreground_colour) self.message.setLineWrap(True) self.message.setWrapStyleWord(True) self.message.setBorder(BorderFactory.createEmptyBorder(3,3,3,3)) self.message.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER,0), self.returnKeyPress) # BUttons quit_btn=JButton("Quit!", actionPerformed=ChatApp().closeEvent, border=self.border2, font=self.btn_font) go_btn=JButton("Send", actionPerformed=self.grabText, border=self.border2, font=self.btn_font) quit_btn.setBackground(background_colour) go_btn.setBackground(background_colour) quit_btn.setForeground(foreground_colour) go_btn.setForeground(foreground_colour) # Make scrollable self.scroll_content=JScrollPane(self.main_content) self.scroll_content.setPreferredSize(Dimension(150,275)) self.scroll_content.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER) self.scroll_content.setViewportView(self.main_content) self.scroll_content.setBackground(Color.WHITE) self.scroll_message=JScrollPane(self.message) self.scroll_message.setPreferredSize(Dimension(150,20)) self.scroll_message.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS) # Test user label, still not updating after first round of messages self.user_label=JLabel(" Users online : %s "%(str(len(self.no_users))),JLabel.RIGHT, font=self.label_2_font) # Assemble the components # Horizontal layout self.client_layout.setHorizontalGroup(self.client_layout.createParallelGroup() .addComponent(self.scroll_content) .addGroup(self.client_layout.createParallelGroup(GroupLayout.Alignment.CENTER) .addComponent(self.scroll_message)) .addGroup(self.client_layout.createSequentialGroup() .addComponent(quit_btn) .addComponent(go_btn).addGap(20)) .addGroup(self.client_layout.createParallelGroup() .addComponent(self.user_label)) ) # Vertical layout self.client_layout.setVerticalGroup(self.client_layout.createSequentialGroup() .addGroup(self.client_layout.createParallelGroup() .addComponent(self.scroll_content)) .addComponent(self.scroll_message) .addGroup(self.client_layout.createParallelGroup() .addComponent(quit_btn) .addComponent(go_btn)) .addGroup(self.client_layout.createParallelGroup() .addComponent(self.user_label)) ) # Finalise the GUI self.client_layout.linkSize(SwingConstants.HORIZONTAL, [quit_btn,go_btn, self.user_label]) self.pack() self.message.requestFocusInWindow() self.setTitle(">>> Client %s <<<"%self.username) self.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE) self.setLocationRelativeTo(None) self.setVisible(True) # Display the server greeting self.appendText('\n'+self.greeting+'\n') ## Function responsible for receiving and processing new messages def recvFunction(self): '''A function to control the receiving of data from the connection ''' # While the connection is available while self.tn: # Try to receive data using "<<<" as the delimiter try: message = self.tn.read_until('<<<') # If a message is received if message: garb, message=message.split('>>>') message, garb = message.split('<<<') message = ('\n'+message+'\n') # Call the append text function self.appendText(message) # Except if there is no data available except: #print('No message') pass ## Event driven function to retrieve and send data to the server def grabText(self, event): '''Function to repeatedly grab new messages entered into the text area and display them in the main text area. Resets the entry area ''' # Grab the text from the text area text=self.message.getText() # Don't allow an empty string through if text=='': return text=text.strip() # Call the append text function self.appendText('\nYou : '+text+'\n', self.username) # Reset the text to be empty and grab focus so that it is ready for new text input self.message.requestFocusInWindow() self.message.setText('') # Send the message to the server data=text.encode() self.tn.write(data+'\r\n') ## Function to handle appending of messages def appendText(self, message, user=None): '''This function takes care of appending any new messages to the content area ''' message_label=JTextArea(message,2,3, font=self.label_2_font) # If this is a message from the grab text function, create a new label, assign it's colours if user!=None: message_label.setBackground(Color(240,240,240)) message_label.setForeground(Color(129,129,129)) # Otherwise set the format for receive function (no user passed in) else: message_label.setBackground(Color(215,215,215)) message_label.setForeground(Color(40,153,153)) # Format and style options for the new message labels message_label.setEditable(False) message_label.setLineWrap(True) message_label.setWrapStyleWord(True) message_label.setBorder(BorderFactory.createLineBorder( Color(247,246,242),4)) # Sets the positioning of messages self.main_content.setCaretPosition(self.main_content.getDocument().getLength()) doc = self.main_content.getStyledDocument() attr=SimpleAttributeSet() self.main_content.insertComponent(message_label) # Essential for jtextarea to be able to stack message doc.insertString( self.main_content.getDocument().getLength(),'\n ', attr) # Not sure if needed self.main_content.repaint() ### This is a late edit so it isn't included in the documentation. Basically trying to dynamically update the number ### of users label at runtime. Works for incrementing the value but not decrementing it. print(message) # Only split the message if there are enough values to split (greeting messages differ in format to chat messages) try: user, text=message.split(' : ') except: return #print('Split values are %s %s'%(user, text)) user=str(user.strip()) #print(self.no_users) #print(user+' : '+text) # If the user already in the list, pass if user in self.no_users: if text == ('User %s amach sa teach !'%user): self.no_users.remove(user) print('User % removed'%user) else: #print('User %s not in list'%user) if str(user) == 'You': #print('User is equal to "You"') return self.no_users.append(user) print('User appended') self.number_users=len(self.no_users) #print('Length of user list is '+str(self.number_users)) self.user_label2=JLabel(" Users online : %s "%str(len(self.no_users)),JLabel.RIGHT, font=self.label_2_font) #print('Label created') #print('Attempt to replace label') self.client_layout.replace(self.user_label, self.user_label2) self.user_label = self.user_label2 self.user_label.repaint() self.user_label.revalidate() print('Label updated') ## Function to control return button press in message field def returnKeyPress(self,event): '''This function creates an object for return key press when inside the message entry area, creates an object of KeyAdapter and tests keycode for a match, responds with grab text callback ''' key_object=Key() key_value=key_object.keyPressed(event) if key_value == 10: self.grabText(event)
def __init__(self, callbacks, issue=defaultIssue, title="", modality=""): """Constructor, populates the dialog.""" # set the title self.setTitle(title) # store the issue self.issue = issue from javax.swing import JFrame self.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE) if modality is not "": from java.awt.Dialog import ModalityType modality = modality.lower() # application blocks us from clicking anything else in Burp if modality == "application": self.setModalityType(ModalityType.APPLICATION_MODAL) if modality == "document": self.setModalityType(ModalityType.DOCUMENT_MODAL) if modality == "modeless": self.setModalityType(ModalityType.DOCUMENT_MODAL) if modality == "toolkit": self.setModalityType(ModalityType.DOCUMENT_MODAL) # assert isinstance(callbacks, IBurpExtenderCallbacks) # starting converted code from NetBeans self.labelPath = JLabel("Path") self.labelSeverity = JLabel("Severity") self.tabIssue = JTabbedPane() self.textAreaDescription = JTextArea() self.textAreaRemediation = JTextArea() # JScrollPanes to hold the two jTextAreas # put the textareas in JScrollPanes self.jsPaneDescription = JScrollPane(self.textAreaDescription) self.jsPaneRemediation = JScrollPane(self.textAreaRemediation) self.panelRequest = callbacks.createMessageEditor(None, True) self.panelResponse = callbacks.createMessageEditor(None, True) self.textName = JTextField() self.textHost = JTextField() self.textPath = JTextField() self.labelHost = JLabel("Host") self.labelName = JLabel("Name") # buttons self.buttonSave = JButton("Save", actionPerformed=self.saveButtonAction) self.buttonCancel = JButton("Cancel", actionPerformed=self.cancelButtonAction) self.buttonReset = JButton("Reset", actionPerformed=self.resetButtonAction) # description and remediation textareas from java.awt import Dimension self.textAreaDescription.setPreferredSize(Dimension(400, 500)) self.textAreaDescription.setLineWrap(True) self.textAreaDescription.setWrapStyleWord(True) self.textAreaRemediation.setLineWrap(True) self.textAreaRemediation.setWrapStyleWord(True) self.tabIssue.addTab("Description", self.jsPaneDescription) self.tabIssue.addTab("Remediation", self.jsPaneRemediation) # request and response tabs # request tab self.panelRequest.setMessage("", True) self.tabIssue.addTab("Request", self.panelRequest.getComponent()) # response tab self.panelResponse.setMessage("", False) self.tabIssue.addTab("Response", self.panelResponse.getComponent()) # template self.labelTemplate = JLabel("Template") self.comboTemplate = JComboBox() # TODO: Populate this from outside using a config file from the # constructor? or perhaps the extension config self.comboSeverity = JComboBox( ["Critical", "High", "Medium", "Low", "Info"]) self.comboSeverity.setSelectedIndex(-1) # add componentlistener dlgListener = DialogListener(self) self.addComponentListener(dlgListener) if issue is None: issue = self.defaultIssue # load the issue into the edit dialog. self.loadPanel(issue) # "here be dragons" GUI code layout = GroupLayout(self.getContentPane()) self.getContentPane().setLayout(layout) layout.setHorizontalGroup( layout.createParallelGroup(GroupLayout.Alignment.CENTER).addGroup( layout.createSequentialGroup().addGroup( layout.createParallelGroup(GroupLayout.Alignment.CENTER). addGroup(layout.createSequentialGroup().addContainerGap( ).addGroup(layout.createParallelGroup().addGroup( layout.createSequentialGroup().addGroup( layout.createParallelGroup().addComponent( self.labelTemplate).addComponent( self.labelHost). addComponent(self.labelName)).addPreferredGap( LayoutStyle.ComponentPlacement.UNRELATED). addGroup(layout.createParallelGroup().addGroup( layout.createSequentialGroup().addComponent( self.comboTemplate) ).addGroup(layout.createSequentialGroup().addComponent( self.textHost, GroupLayout.PREFERRED_SIZE, 212, GroupLayout.PREFERRED_SIZE).addPreferredGap( LayoutStyle.ComponentPlacement.UNRELATED ).addComponent(self.labelPath).addPreferredGap( LayoutStyle.ComponentPlacement.RELATED ).addComponent( self.textPath, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, 800 )).addGroup( GroupLayout.Alignment.TRAILING, layout.createSequentialGroup(). addComponent(self.textName).addPreferredGap( LayoutStyle.ComponentPlacement.UNRELATED). addComponent( self.labelSeverity).addPreferredGap( LayoutStyle.ComponentPlacement. UNRELATED).addComponent( self.comboSeverity, GroupLayout.PREFERRED_SIZE, 182, GroupLayout.PREFERRED_SIZE))) ).addComponent(self.tabIssue))).addGroup( layout.createSequentialGroup().addComponent( self.buttonSave, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE).addComponent( self.buttonReset, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE).addComponent( self.buttonCancel, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout. PREFERRED_SIZE))).addContainerGap())) # link size of buttons together from javax.swing import SwingConstants layout.linkSize(SwingConstants.HORIZONTAL, [self.buttonCancel, self.buttonSave, self.buttonReset]) layout.setVerticalGroup(layout.createParallelGroup().addGroup( GroupLayout.Alignment.TRAILING, layout.createSequentialGroup().addContainerGap().addGroup( layout.createParallelGroup( GroupLayout.Alignment.BASELINE).addComponent( self.labelName).addComponent( self.textName, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE).addComponent( self.labelSeverity).addComponent( self.comboSeverity, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)). addPreferredGap(LayoutStyle.ComponentPlacement.RELATED).addGroup( layout.createParallelGroup( GroupLayout.Alignment.BASELINE).addComponent( self.textHost, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE).addComponent( self.labelPath).addComponent(self.textPath). addComponent(self.labelHost)).addGroup( layout.createParallelGroup( GroupLayout.Alignment.BASELINE).addComponent( self.comboTemplate, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE).addComponent( self.labelTemplate)).addPreferredGap( LayoutStyle.ComponentPlacement.RELATED). addComponent(self.tabIssue).addPreferredGap( LayoutStyle.ComponentPlacement.RELATED).addGroup( layout.createParallelGroup().addComponent( self.buttonSave).addComponent( self.buttonReset).addComponent( self.buttonCancel)).addContainerGap())) # end of converted code from NetBeans # set the template label and combobox to invisible self.labelTemplate.setVisible(False) self.comboTemplate.setVisible(False)
def __init__(self): TrafficMod.__init__(self) self.setLayout(FlowLayout(FlowLayout.LEADING)) settings_panel = JPanel() layout = GroupLayout(settings_panel) layout.setAutoCreateGaps(True) layout.setAutoCreateContainerGaps(True) settings_panel.setLayout(layout) self.add(settings_panel) # Horizontal group horizontal = layout.createParallelGroup() layout.setHorizontalGroup( layout.createSequentialGroup().addGroup(horizontal)) # Vertical group vertical = layout.createSequentialGroup() layout.setVerticalGroup(vertical) # Main title, label only main_title = JLabel(self.title) main_title.setFont(get_title_font(main_title)) horizontal.addGroup( layout.createSequentialGroup().addComponent(main_title)) vertical.addGroup( layout.createParallelGroup( GroupLayout.Alignment.BASELINE).addComponent(main_title)) # loss type (random, state, or gemodel) self.loss_type_combo = self.get_loss_type_combo() loss_type_lbl = JLabel("Loss type") horizontal.addGroup(layout.createSequentialGroup().addComponent( loss_type_lbl).addComponent(self.loss_type_combo)) vertical.addGroup( layout.createParallelGroup( GroupLayout.Alignment.BASELINE).addComponent( loss_type_lbl).addComponent(self.loss_type_combo)) # Random loss fields # Loss percentage loss_percent_lbl = JLabel("Loss %") horizontal.addGroup(layout.createSequentialGroup().addComponent( loss_percent_lbl).addComponent(self.loss_random_percent)) vertical.addGroup( layout.createParallelGroup( GroupLayout.Alignment.BASELINE).addComponent( loss_percent_lbl).addComponent(self.loss_random_percent)) layout.linkSize(SwingConstants.HORIZONTAL, loss_percent_lbl, loss_type_lbl) self.loss_random_items.append(loss_percent_lbl) self.loss_random_items.append(self.loss_random_percent) # Loss percent correlation loss_corr_lbl = JLabel("Correlation %") horizontal.addGroup(layout.createSequentialGroup().addComponent( loss_corr_lbl).addComponent(self.loss_random_percent_correlation)) vertical.addGroup( layout.createParallelGroup( GroupLayout.Alignment.BASELINE).addComponent( loss_corr_lbl).addComponent( self.loss_random_percent_correlation)) layout.linkSize(SwingConstants.HORIZONTAL, loss_corr_lbl, loss_type_lbl) self.loss_random_items.append(loss_corr_lbl) self.loss_random_items.append(self.loss_random_percent_correlation) # State loss fields # P13 loss_p13_lbl = JLabel("P13") horizontal.addGroup(layout.createSequentialGroup().addComponent( loss_p13_lbl).addComponent(self.loss_state_p13)) vertical.addGroup( layout.createParallelGroup( GroupLayout.Alignment.BASELINE).addComponent( loss_p13_lbl).addComponent(self.loss_state_p13)) self.loss_state_items.append(loss_p13_lbl) self.loss_state_items.append(self.loss_state_p13) # P31 loss_p31_lbl = JLabel("P31") horizontal.addGroup(layout.createSequentialGroup().addComponent( loss_p31_lbl).addComponent(self.loss_state_p31)) vertical.addGroup( layout.createParallelGroup( GroupLayout.Alignment.BASELINE).addComponent( loss_p31_lbl).addComponent(self.loss_state_p31)) layout.linkSize(SwingConstants.HORIZONTAL, loss_p31_lbl, loss_p13_lbl) self.loss_state_items.append(loss_p31_lbl) self.loss_state_items.append(self.loss_state_p31) # P32 loss_p32_lbl = JLabel("P32") horizontal.addGroup(layout.createSequentialGroup().addComponent( loss_p32_lbl).addComponent(self.loss_state_p32)) vertical.addGroup( layout.createParallelGroup( GroupLayout.Alignment.BASELINE).addComponent( loss_p32_lbl).addComponent(self.loss_state_p32)) layout.linkSize(SwingConstants.HORIZONTAL, loss_p32_lbl, loss_p13_lbl) self.loss_state_items.append(loss_p32_lbl) self.loss_state_items.append(self.loss_state_p32) # P23 loss_p23_lbl = JLabel("P23") horizontal.addGroup(layout.createSequentialGroup().addComponent( loss_p23_lbl).addComponent(self.loss_state_p23)) vertical.addGroup( layout.createParallelGroup( GroupLayout.Alignment.BASELINE).addComponent( loss_p23_lbl).addComponent(self.loss_state_p23)) layout.linkSize(SwingConstants.HORIZONTAL, loss_p23_lbl, loss_p13_lbl) self.loss_state_items.append(loss_p23_lbl) self.loss_state_items.append(self.loss_state_p23) # P14 loss_p14_lbl = JLabel("P14") horizontal.addGroup(layout.createSequentialGroup().addComponent( loss_p14_lbl).addComponent(self.loss_state_p14)) vertical.addGroup( layout.createParallelGroup( GroupLayout.Alignment.BASELINE).addComponent( loss_p14_lbl).addComponent(self.loss_state_p14)) layout.linkSize(SwingConstants.HORIZONTAL, loss_p14_lbl, loss_p13_lbl) self.loss_state_items.append(loss_p14_lbl) self.loss_state_items.append(self.loss_state_p14) # Gemodel loss fields # P ge_p_lbl = JLabel("p") horizontal.addGroup( layout.createSequentialGroup().addComponent(ge_p_lbl).addComponent( self.loss_gemodel_p)) vertical.addGroup( layout.createParallelGroup( GroupLayout.Alignment.BASELINE).addComponent( ge_p_lbl).addComponent(self.loss_gemodel_p)) self.loss_gemodel_items.append(ge_p_lbl) self.loss_gemodel_items.append(self.loss_gemodel_p) # R ge_r_lbl = JLabel("r") horizontal.addGroup( layout.createSequentialGroup().addComponent(ge_r_lbl).addComponent( self.loss_gemodel_r)) vertical.addGroup( layout.createParallelGroup( GroupLayout.Alignment.BASELINE).addComponent( ge_r_lbl).addComponent(self.loss_gemodel_r)) layout.linkSize(SwingConstants.HORIZONTAL, ge_r_lbl, ge_p_lbl) self.loss_gemodel_items.append(ge_r_lbl) self.loss_gemodel_items.append(self.loss_gemodel_r) # H ge_h_lbl = JLabel("1-h") horizontal.addGroup( layout.createSequentialGroup().addComponent(ge_h_lbl).addComponent( self.loss_gemodel_h)) vertical.addGroup( layout.createParallelGroup( GroupLayout.Alignment.BASELINE).addComponent( ge_h_lbl).addComponent(self.loss_gemodel_h)) layout.linkSize(SwingConstants.HORIZONTAL, ge_h_lbl, ge_p_lbl) self.loss_gemodel_items.append(ge_h_lbl) self.loss_gemodel_items.append(self.loss_gemodel_h) # K ge_k_lbl = JLabel("1-k") horizontal.addGroup( layout.createSequentialGroup().addComponent(ge_k_lbl).addComponent( self.loss_gemodel_k)) vertical.addGroup( layout.createParallelGroup( GroupLayout.Alignment.BASELINE).addComponent( ge_k_lbl).addComponent(self.loss_gemodel_k)) layout.linkSize(SwingConstants.HORIZONTAL, ge_k_lbl, ge_p_lbl) self.loss_gemodel_items.append(ge_k_lbl) self.loss_gemodel_items.append(self.loss_gemodel_k) # Initially show the loss_random textboxes for item in self.loss_random_items: item.setVisible(True) for item in self.loss_state_items: item.setVisible(False) for item in self.loss_gemodel_items: item.setVisible(False)
def __init__(self): TrafficMod.__init__(self) self.setLayout(FlowLayout(FlowLayout.LEADING)) settings_panel = JPanel() layout = GroupLayout(settings_panel) layout.setAutoCreateGaps(True) layout.setAutoCreateContainerGaps(True) settings_panel.setLayout(layout) self.add(settings_panel) # Horizontal group horizontal = layout.createParallelGroup() layout.setHorizontalGroup( layout.createSequentialGroup().addGroup(horizontal)) # Vertical group vertical = layout.createSequentialGroup() layout.setVerticalGroup(vertical) # Main title, label only main_title = JLabel(self.title) main_title.setFont(get_title_font(main_title)) horizontal.addGroup( layout.createSequentialGroup().addComponent(main_title)) vertical.addGroup( layout.createParallelGroup( GroupLayout.Alignment.BASELINE).addComponent(main_title)) # Base rate delay_lbl = JLabel("Delay") horizontal.addGroup(layout.createSequentialGroup().addComponent( delay_lbl).addComponent(self.delay_time).addComponent( self.times_combo)) vertical.addGroup( layout.createParallelGroup( GroupLayout.Alignment.BASELINE).addComponent( delay_lbl).addComponent(self.delay_time).addComponent( self.times_combo)) # Deviation (jitter) deviation_lbl = JLabel("Deviation") horizontal.addGroup(layout.createSequentialGroup().addComponent( deviation_lbl).addComponent(self.delay_deviation).addComponent( self.deviation_combo)) vertical.addGroup( layout.createParallelGroup(GroupLayout.Alignment.BASELINE). addComponent(deviation_lbl).addComponent( self.delay_deviation).addComponent(self.deviation_combo)) layout.linkSize(SwingConstants.HORIZONTAL, deviation_lbl, delay_lbl) # Correlation corr_lbl = JLabel("Correlation %") horizontal.addGroup( layout.createSequentialGroup().addComponent(corr_lbl).addComponent( self.delay_correlation)) vertical.addGroup( layout.createParallelGroup( GroupLayout.Alignment.BASELINE).addComponent( corr_lbl).addComponent(self.delay_correlation)) layout.linkSize(SwingConstants.HORIZONTAL, corr_lbl, delay_lbl) # Distribution dist_lbl = JLabel("Distribution") horizontal.addGroup( layout.createSequentialGroup().addComponent(dist_lbl).addComponent( self.distribution_combo)) vertical.addGroup( layout.createParallelGroup( GroupLayout.Alignment.BASELINE).addComponent( dist_lbl).addComponent(self.distribution_combo)) layout.linkSize(SwingConstants.HORIZONTAL, dist_lbl, delay_lbl)
def __init__(self): TrafficMod.__init__(self) self.setLayout(FlowLayout(FlowLayout.LEADING)) settings_panel = JPanel() # settings_panel.setBorder(LineBorder(Color.RED)) layout = GroupLayout(settings_panel) layout.setAutoCreateGaps(True) layout.setAutoCreateContainerGaps(True) settings_panel.setLayout(layout) self.add(settings_panel) # Horizontal group horizontal = layout.createParallelGroup() layout.setHorizontalGroup( layout.createSequentialGroup().addGroup(horizontal)) self.horizontal_layout = horizontal # Vertical group vertical = layout.createSequentialGroup() layout.setVerticalGroup(vertical) self.vertical_layout = vertical # Main title, label only main_title = JLabel(self.title) main_title.setFont(get_title_font(main_title)) horizontal.addGroup( layout.createSequentialGroup().addComponent(main_title)) vertical.addGroup( layout.createParallelGroup( GroupLayout.Alignment.BASELINE).addComponent(main_title)) rates_combo = ui_components.get_rate_combo() # Base rate rate_lbl = JLabel("Rate") rate_lbl.setToolTipText( "Simulates a network connector with a limited throughput") horizontal.addGroup( layout.createSequentialGroup().addComponent(rate_lbl).addComponent( self.rate_textfield).addComponent(rates_combo)) vertical.addGroup( layout.createParallelGroup( GroupLayout.Alignment.BASELINE).addComponent( rate_lbl).addComponent( self.rate_textfield).addComponent(rates_combo)) # Packet overhead packet_overhead_lbl = JLabel("Packet Overhead") horizontal.addGroup(layout.createSequentialGroup().addComponent( packet_overhead_lbl).addComponent(self.packet_textfield)) vertical.addGroup( layout.createParallelGroup( GroupLayout.Alignment.BASELINE).addComponent( packet_overhead_lbl).addComponent(self.packet_textfield)) layout.linkSize(SwingConstants.HORIZONTAL, packet_overhead_lbl, rate_lbl) # Cell size cell_size_lbl = JLabel("Cell Size") horizontal.addGroup(layout.createSequentialGroup().addComponent( cell_size_lbl).addComponent(self.cellsize_textfield)) vertical.addGroup( layout.createParallelGroup( GroupLayout.Alignment.BASELINE).addComponent( cell_size_lbl).addComponent(self.cellsize_textfield)) layout.linkSize(SwingConstants.HORIZONTAL, cell_size_lbl, rate_lbl) # Cell overhead cell_overhead_lbl = JLabel("Cell Overhead") horizontal.addGroup(layout.createSequentialGroup().addComponent( cell_overhead_lbl).addComponent(self.celloverhead_textfield)) vertical.addGroup( layout.createParallelGroup( GroupLayout.Alignment.BASELINE).addComponent( cell_overhead_lbl).addComponent( self.celloverhead_textfield)) layout.linkSize(SwingConstants.HORIZONTAL, cell_overhead_lbl, rate_lbl)
def edit_filter_panel(self): edit_panel = JPanel() layout = GroupLayout(edit_panel) layout.setAutoCreateGaps(True) # layout.setAutoCreateContainerGaps(True) edit_panel.setLayout(layout) # Horizontal group horizontal = layout.createParallelGroup() layout.setHorizontalGroup( layout.createSequentialGroup().addGroup(horizontal)) # Vertical group vertical = layout.createSequentialGroup() layout.setVerticalGroup(vertical) # Main title, label only # main_title = JLabel(self.title) # main_title.setFont(get_title_font(main_title)) # horizontal.addGroup(layout.createSequentialGroup() # .addComponent(main_title)) # vertical.addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE) # .addComponent(main_title)) # Packet source IP address src_ip_lbl = JLabel("Source IP Addr") src_ip_fld = JTextField() horizontal.addGroup(layout.createSequentialGroup().addComponent( src_ip_lbl).addComponent(src_ip_fld)) vertical.addGroup( layout.createParallelGroup( GroupLayout.Alignment.BASELINE).addComponent( src_ip_lbl).addComponent(src_ip_fld)) # Packet source port src_port_lbl = JLabel("Source Port") src_port_fld = JTextField() horizontal.addGroup(layout.createSequentialGroup().addComponent( src_port_lbl).addComponent(src_port_fld)) vertical.addGroup( layout.createParallelGroup( GroupLayout.Alignment.BASELINE).addComponent( src_port_lbl).addComponent(src_port_fld)) layout.linkSize(SwingConstants.HORIZONTAL, src_port_lbl, src_ip_lbl) # Packet destination IP address dest_ip_lbl = JLabel("Destination IP Addr") dest_ip_fld = JTextField() horizontal.addGroup(layout.createSequentialGroup().addComponent( dest_ip_lbl).addComponent(dest_ip_fld)) vertical.addGroup( layout.createParallelGroup( GroupLayout.Alignment.BASELINE).addComponent( dest_ip_lbl).addComponent(dest_ip_fld)) layout.linkSize(SwingConstants.HORIZONTAL, dest_ip_lbl, src_ip_lbl) # Packet destination port dest_port_lbl = JLabel("Destination Port") dest_port_fld = JTextField() horizontal.addGroup(layout.createSequentialGroup().addComponent( dest_port_lbl).addComponent(dest_port_fld)) vertical.addGroup( layout.createParallelGroup( GroupLayout.Alignment.BASELINE).addComponent( dest_port_lbl).addComponent(dest_port_fld)) layout.linkSize(SwingConstants.HORIZONTAL, dest_port_lbl, src_ip_lbl) return edit_panel
def initUI(self): inputPanel = JPanel() inputPanel.setBorder(BorderFactory.createTitledBorder("Where are your control and treament images?")) inputLayout = GroupLayout(inputPanel, autoCreateContainerGaps=True, autoCreateGaps=True) inputPanel.setLayout(inputLayout) annotatePanel = JPanel() annotatePanel.setBorder(BorderFactory.createTitledBorder("How do you want to annotate your data?")) anLayout = GroupLayout(annotatePanel, autoCreateContainerGaps=True, autoCreateGaps=True) annotatePanel.setLayout(anLayout) exportPanel = JPanel() exportPanel.setBorder(BorderFactory.createTitledBorder("Where do you want to export your data")) exportLayout = GroupLayout(exportPanel, autoCreateContainerGaps=True, autoCreateGaps=True) exportPanel.setLayout(exportLayout) btnPanel = JPanel() btnLayout = GroupLayout(btnPanel, autoCreateContainerGaps=True, autoCreateGaps=True) btnPanel.setLayout(btnLayout) layout = GroupLayout(self.getContentPane(), autoCreateContainerGaps=True, autoCreateGaps=True) self.getContentPane().setLayout(layout) self.setModalityType(ModalityType.APPLICATION_MODAL) self.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE)# JFrame.EXIT_ON_CLOSE) # definition of elements # labels cPathLabel = JLabel("Control Path:") tPathLabel = JLabel("Treatment Path:") exPathLabel = JLabel("Save Results in:") #textfields self.cPathField = JTextField("/Users/schiklen/DotData/131118_dummy/131118_2926/cutout/", 16) self.tPathField = JTextField("/Users/schiklen/DotData/131118_dummy/131118_2926/cutout/", 16) self.exPathField = JTextField("/Users/schiklen/DotData/131118_dummy/131118_2926/cutout/", 16) #Radiobuttons yesNoRButton = JRadioButton("Yes / No / Ignore", selected=True, actionCommand="yesNoIgnore", actionPerformed=self.setAnnotationTypeDialog) intRButton = JRadioButton("Integer", actionCommand="int", actionPerformed=self.setAnnotationTypeDialog) nRButton = JRadioButton("Number", actionCommand="float", actionPerformed=self.setAnnotationTypeDialog) listRButton = JRadioButton("From List...", actionCommand="list", actionPerformed=self.openListDialog) self.rBGroup = ButtonGroup() self.rBGroup.add(yesNoRButton) self.rBGroup.add(intRButton) self.rBGroup.add(nRButton) self.rBGroup.add(listRButton) #self.customListButton = JButton("Custom List...", actionPerformed=self.makeCustomList, enabled=0) #buttons cPathButton = JButton("Browse...", actionPerformed=self.browseC) # lambda on fieldvalue tPathButton = JButton("Browse...", actionPerformed=self.browseT) # lambda on fieldvalue exPathButton = JButton("Browse...", actionPerformed=self.browseE) OKButton = JButton("OK", actionPerformed=self.okayEvent) CancelButton = JButton("Cancel", actionPerformed=self.cancel) '''General ContentPane Layout''' layout.setHorizontalGroup(layout.createParallelGroup() .addComponent(inputPanel) .addComponent(annotatePanel) .addComponent(exportPanel) .addComponent(btnPanel) ) layout.linkSize(SwingConstants.HORIZONTAL, inputPanel, annotatePanel, exportPanel, btnPanel) layout.setVerticalGroup(layout.createSequentialGroup() .addComponent(inputPanel) .addComponent(annotatePanel) .addComponent(exportPanel) .addComponent(btnPanel) ) ''' Input panel Layout ''' inputLayout.setHorizontalGroup(inputLayout.createSequentialGroup() .addGroup(inputLayout.createParallelGroup(GroupLayout.Alignment.TRAILING) .addComponent(cPathLabel) .addComponent(tPathLabel)) .addGroup(inputLayout.createParallelGroup(GroupLayout.Alignment.TRAILING) .addComponent(self.cPathField) .addComponent(self.tPathField)) .addGroup(inputLayout.createParallelGroup() .addComponent(cPathButton) .addComponent(tPathButton)) ) inputLayout.setVerticalGroup(inputLayout.createSequentialGroup() .addGroup(inputLayout.createParallelGroup(GroupLayout.Alignment.BASELINE) .addComponent(cPathLabel) .addComponent(self.cPathField) .addComponent(cPathButton)) .addGroup(inputLayout.createParallelGroup(GroupLayout.Alignment.BASELINE) .addComponent(tPathLabel) .addComponent(self.tPathField) .addComponent(tPathButton)) ) '''Annotate panel layout''' anLayout.setHorizontalGroup(anLayout.createParallelGroup() .addComponent(yesNoRButton) .addComponent(intRButton) .addComponent(nRButton) .addComponent(listRButton) #.addComponent(self.customListButton) ) anLayout.setVerticalGroup(anLayout.createSequentialGroup() .addComponent(yesNoRButton) .addComponent(intRButton) .addComponent(nRButton) .addComponent(listRButton) #.addComponent(self.customListButton) ) '''Export panel layout''' exportLayout.setHorizontalGroup(exportLayout.createSequentialGroup() .addComponent(exPathLabel) .addComponent(self.exPathField) .addComponent(exPathButton)) exportLayout.setVerticalGroup(exportLayout.createParallelGroup(GroupLayout.Alignment.BASELINE) .addComponent(exPathLabel) .addComponent(self.exPathField) .addComponent(exPathButton)) '''Buttons Panel Layout''' btnLayout.setHorizontalGroup(btnLayout.createSequentialGroup() .addComponent(CancelButton) .addComponent(OKButton) ) btnLayout.setVerticalGroup(btnLayout.createParallelGroup(GroupLayout.Alignment.BASELINE) .addComponent(CancelButton) .addComponent(OKButton) ) self.setTitle("Random Picture Picker") self.pack() self.setLocationRelativeTo(None) self.setVisible(True)
def __init__(self): super(WorkHelper, self).__init__() self.clipboard = Toolkit.getDefaultToolkit().getSystemClipboard() #self.initUI() #def initUI(self): #panel = JPanel() #self.getContentPane().add(panel) ############################################################# # Layout layout = GroupLayout(self.getContentPane()) self.getContentPane().setLayout(layout) layout.setAutoCreateGaps(True) layout.setAutoCreateContainerGaps(True) ############################################################# ############################################################# # Scroll Area Input + Output Larea1 = JLabel("InputArea:") Larea2 = JLabel("OutputArea:") Sarea1 = JScrollPane() Sarea2 = JScrollPane() self.area1 = JTextArea() self.area1.setToolTipText("Input Area") self.area1.setEditable(True) self.area1.setBorder(BorderFactory.createLineBorder(Color.gray)) Sarea1.setPreferredSize(Dimension(300,100)) Sarea1.getViewport().setView((self.area1)) self.area2 = JTextArea() self.area2.setToolTipText("Output Area") self.area2.setEditable(False) self.area2.setBorder(BorderFactory.createLineBorder(Color.gray)) Sarea2.setPreferredSize(Dimension(300,100)) Sarea2.getViewport().setView((self.area2)) ############################################################# ############################################################# # Buttons self.cCurly = JCheckBox("Curly"); self.cCurly.setToolTipText("When 'Checked' Curly Brackets will surround the Categories") self.cCurly.setSelected(1) self.cCtClipB = JCheckBox("Auto-Copy"); self.cCtClipB.setToolTipText("When 'Checked' after the Categories are created they will added to the clipboard") self.cCtClipB.setSelected(1) self.cSemiC = JCheckBox("SemiColumn"); self.cSemiC.setToolTipText("When 'Checked' after the Categories are created at the end will be a semicolomn") self.cSemiC.setSelected(1) bRemoveNBSP_L = JButton("Clean LText", actionPerformed=self.bRemoveNBSP_L) bRemoveNBSP_L.setToolTipText("Removes Spaces, Tabs from the start of every text line from the input Area") bRemoveNBSP_R = JButton("Clean RText", actionPerformed=self.bRemoveNBSP_R) bRemoveNBSP_R.setToolTipText("Removes Spaces, Tabs from the end of every text line from the input Area") bCopyToInput = JButton("Copy to Input", actionPerformed=self.bCopyToInput) bCopyToInput.setToolTipText("Copy the text from the Output Area to the Input Area for further Operations") bClear = JButton("Clear", actionPerformed=self.bClear) bClear.setToolTipText("Clears the text form both Input and Output text Areas") self.iStart = JTextField(maximumSize=Dimension(40,25)) self.iStart.setToolTipText("The Start Index for the Making of the Categories") self.RThis = JTextField() self.RThis = JTextField(maximumSize=Dimension(120,25)) self.RThis.setToolTipText("Text to be replaced or The Starting C_Index") self.RThat = JTextField() self.RThat = JTextField(maximumSize=Dimension(120,25)) self.RThat.setToolTipText("Text to be placed or The Finish C_Index") bSandReplace = JButton("Replace Text", actionPerformed=self.bSandReplace) bSandReplace.setToolTipText("Replace the text from This with Thext from That in the Text from the Input Area and displays it in the Output Area") bcCat = JButton("CreatCateg", actionPerformed=self.bcCat) bcCat.setToolTipText("Create a categorical form starting C_Index to finish C_Index; Use the above text boxes to define the indexes") bC_S = JButton("Create _Series", actionPerformed=self.bC_S) bC_S.setToolTipText("Create a series form starting C_Index to finish C_Index; Use the above text boxes to define the indexes; It will create a series for every row in the Input Area") bM_Categories = JButton("Categories", actionPerformed=self.mCategories) bM_Categories.setToolTipText("Make Categories using the lines from the Input Area") #bM_Categories = JButton(maximumSize=Dimension(40,25)) # de incercat daca merge cu ; sa grupezi in [dsa] elementele ############################################################# ############################################################# # Aplication Layout 2 groups one Horizontal and one Vertical layout.setHorizontalGroup(layout.createSequentialGroup() .addGroup(layout.createParallelGroup() .addComponent(Larea1) .addComponent(Sarea1) .addComponent(Sarea2) .addComponent(bCopyToInput) .addComponent(Larea2)) .addGroup(layout.createParallelGroup() .addGroup(layout.createSequentialGroup() .addComponent(bM_Categories) .addComponent(self.iStart)) .addGroup(layout.createSequentialGroup() .addComponent(self.cCurly) .addComponent(self.cSemiC) .addComponent(self.cCtClipB)) .addGroup(layout.createSequentialGroup() .addComponent(bRemoveNBSP_L) .addComponent(bRemoveNBSP_R)) .addGroup(layout.createSequentialGroup() .addComponent(self.RThis) .addComponent(self.RThat)) .addGroup(layout.createSequentialGroup() .addComponent(bSandReplace) .addComponent(bcCat)) .addGroup(layout.createSequentialGroup() .addComponent(bC_S)) .addComponent(bClear)) ) layout.setVerticalGroup(layout.createSequentialGroup() .addComponent(Larea1) .addGroup(layout.createParallelGroup() .addComponent(Sarea1) .addGroup(layout.createSequentialGroup() .addGroup(layout.createParallelGroup() .addComponent(bM_Categories) .addComponent(self.iStart)) .addGroup(layout.createParallelGroup() .addComponent(self.cCurly) .addComponent(self.cSemiC) .addComponent(self.cCtClipB)) .addGroup(layout.createParallelGroup() .addComponent(bRemoveNBSP_L) .addComponent(bRemoveNBSP_R)) .addGroup(layout.createParallelGroup() .addComponent(self.RThis) .addComponent(self.RThat)) .addGroup(layout.createParallelGroup() .addComponent(bSandReplace) .addComponent(bcCat)) .addGroup(layout.createParallelGroup() .addComponent(bC_S)) ) ) .addGroup(layout.createParallelGroup() .addComponent(bCopyToInput) .addComponent(bClear)) .addComponent(Larea2) .addGroup(layout.createParallelGroup() .addComponent(Sarea2)) ) #layout.linkSize(SwingConstants.HORIZONTAL, [ok, bCopyToInput, close, bM_Categories]) layout.linkSize(SwingConstants.HORIZONTAL, [self.RThis,self.RThat,bRemoveNBSP_L,bRemoveNBSP_R,bCopyToInput,bM_Categories,bSandReplace,bcCat,bC_S]) #layout.linkSize(SwingConstants.HORIZONTAL, [self.cCurly,bM_Categories]) ############################################################# ############################################################# # Aplication Settings self.pack() #self.setPreferredSize(Dimension(1000, 1000)) self.setTitle("Workhelper") self.setSize(800, 500) self.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE) self.setLocationRelativeTo(None) self.setVisible(True)