Ejemplo n.º 1
0
class TaskPanel(Panel):
    def __init__(self, name="Tasks", parent=None):
        Panel.__init__(self, name, "Tasks", parent)

        self.setAttr("refreshSeconds", 5)

        self.setWidget(TaskWidget(self.attrs, self))
        self.setWindowTitle(name)

        self.__lastJobId = None

        EventManager.JobOfInterest.connect(self.__handleJobOfInterestEvent)
        EventManager.LayerOfInterest.connect(self.__handleLayerOfInterestEvent)

    def init(self):
        titleBar = self.titleBarWidget()

        self.__state_filter = CheckableComboBox("Task States",
                                                constants.TASK_STATES,
                                                parent=self)
        self.__layer_filter = CheckableComboBox("Layers", [], parent=self)

        titleBar.addWidget(self.__state_filter)
        titleBar.addWidget(self.__layer_filter)

        self.__state_filter.optionSelected.connect(self.__stateFilterChanged)
        self.__layer_filter.optionSelected.connect(self.__layerFilterChanged)

    def openLoadDialog(self):
        print "Open search dialog"

    def openConfigDialog(self):
        pass

    def refresh(self):
        self.widget().refresh()

    def __handleJobOfInterestEvent(self, jobId, *args, **kwargs):
        taskWidget = self.widget()
        taskWidget.setJobId(jobId)

        if jobId != self.__lastJobId:
            self.__layer_filter.setOptions(taskWidget.layerNames)

        self.__lastJobId = jobId

    def __handleLayerOfInterestEvent(self, layerId, *args, **kwargs):
        taskWidget = self.widget()
        taskWidget.setLayerFilters(layers=[layerId])
        name = taskWidget.layerIdToName(layerId)
        if name:
            self.__layer_filter.setSelected([name])

    def __stateFilterChanged(self):
        sel = self.__state_filter.selectedOptions()
        self.widget().setStateFilters(sel)

    def __layerFilterChanged(self):
        sel = self.__layer_filter.selectedOptions()
        self.widget().setLayerFilters(sel)
Ejemplo n.º 2
0
Archivo: tasks.py Proyecto: Br3nda/plow
class TaskPanel(Panel):

    def __init__(self, name="Tasks", parent=None):
        Panel.__init__(self, name, "Tasks", parent)

        self.setAttr("refreshSeconds", 5)

        self.setWidget(TaskWidget(self.attrs, self))
        self.setWindowTitle(name)

        self.__lastJobId = None

        EventManager.JobOfInterest.connect(self.__handleJobOfInterestEvent)
        EventManager.LayerOfInterest.connect(self.__handleLayerOfInterestEvent)

    def init(self):
        titleBar = self.titleBarWidget()

        self.__state_filter = CheckableComboBox("Task States", constants.TASK_STATES, parent=self)
        self.__layer_filter = CheckableComboBox("Layers", [], parent=self)

        titleBar.addWidget(self.__state_filter)    
        titleBar.addWidget(self.__layer_filter)

        self.__state_filter.optionSelected.connect(self.__stateFilterChanged)
        self.__layer_filter.optionSelected.connect(self.__layerFilterChanged)

    def openLoadDialog(self):
        print "Open search dialog"

    def openConfigDialog(self):
        pass

    def refresh(self):
        self.widget().refresh()

    def __handleJobOfInterestEvent(self, jobId, *args, **kwargs):
        taskWidget = self.widget()
        taskWidget.setJobId(jobId)

        if jobId != self.__lastJobId:
            self.__layer_filter.setOptions(taskWidget.layerNames)

        self.__lastJobId = jobId

    def __handleLayerOfInterestEvent(self, layerId, *args, **kwargs):
        taskWidget = self.widget()
        taskWidget.setLayerFilters(layers=[layerId])
        name = taskWidget.layerIdToName(layerId)
        if name:
            self.__layer_filter.setSelected([name])

    def __stateFilterChanged(self):
        sel = self.__state_filter.selectedOptions()
        self.widget().setStateFilters(sel)

    def __layerFilterChanged(self):
        sel = self.__layer_filter.selectedOptions()
        self.widget().setLayerFilters(sel)
Ejemplo n.º 3
0
class NodePanel(Panel):

    def __init__(self, name="Nodes", parent=None):
        Panel.__init__(self, name, "Nodes", parent)

        self.setAttr("refreshSeconds", 10)

        self.setWidget(NodeWidget(self.attrs, self))
        self.setWindowTitle(name)

    def init(self):
        titleBar = self.titleBarWidget() 
        titleBar.addAction(QtGui.QIcon(":/images/locked.png"), 
                                       "Lock Selected Nodes", 
                                       partial(self.__setNodesLocked, True))

        titleBar.addAction(QtGui.QIcon(":/images/unlocked.png"), 
                                       "Unlock Selected Nodes", 
                                       partial(self.__setNodesLocked, False))

        self.__cluster_filter = CheckableComboBox("Clusters", [], parent=self)
        titleBar.addWidget(self.__cluster_filter)
        self.__cluster_filter.optionSelected.connect(self.__clusterFilterChanged)

    def refresh(self):
        clusters = plow.client.get_clusters()
        names = sorted(c.name for c in clusters)

        nodeWidget = self.widget()
        nodeWidget.refresh()
        nodeWidget.setClusterList(clusters)

        filt = self.__cluster_filter
        sel = filt.selectedOptions()
        filt.setOptions(names, selected=sel)

    def __setNodesLocked(self, locked):
        try:
            for node in self.widget().getSelectedNodes():
                node.lock(locked)
        finally:
            self.refresh()

    def __clusterFilterChanged(self):
        sel = self.__cluster_filter.selectedOptions()
        self.widget().setClusterFilters(sel)