Skip to content

Commit

Permalink
Fixed bug size row
Browse files Browse the repository at this point in the history
  • Loading branch information
Oscar Martinez committed Mar 3, 2019
1 parent 47ac11d commit 55afc67
Show file tree
Hide file tree
Showing 4 changed files with 277 additions and 275 deletions.
8 changes: 4 additions & 4 deletions package.info
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
#
#Sun Mar 03 18:18:26 CET 2019
#Sun Mar 03 18:55:55 CET 2019
owner=gvSIG Association
code=TabbedToC
java-version=j1_7
official=true
type=Script
version=1.0.0-3
version=1.0.0-4
state=testing
operating-system=all
dependencies=
Expand All @@ -16,7 +16,7 @@ model-version=1.0.1
categories=View
description=New Table of Contents in the View to handle layers ordered by drawing, source, visibility or selection
owner-url=
buildNumber=3
download-url=https\://github.com/gvSIGAssociation/gvsig-desktop-scripting-TabbedToC/releases/download/1.0.0-3/gvSIG-desktop-2.5.0-TabbedToC-1.0.0-3-testing-all-all-j1_7.gvspkg
buildNumber=4
download-url=https\://github.com/gvSIGAssociation/gvsig-desktop-scripting-TabbedToC/releases/download/1.0.0-4/gvSIG-desktop-2.5.0-TabbedToC-1.0.0-4-testing-all-all-j1_7.gvspkg
gvSIG-version=2.5.0
name=Tabbed ToC
242 changes: 122 additions & 120 deletions selectionorder.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ def __init__(self,tree,mapContext):
self.mapContext = mapContext

def mouseClicked(self, event):

x = event.getX()
y = event.getY()
row = self.tree.getRowForLocation(x,y)
Expand All @@ -104,11 +103,11 @@ def mouseClicked(self, event):
uo = node.getUserObject()
feature = uo.getFeature()
if x>42 and x<62:
layer = node.getUserObject().getLayer()
layer.getDataStore().getFeatureSelection().deselect(feature)
layer = node.getUserObject().getLayer()
layer.getDataStore().getFeatureSelection().deselect(feature)
elif x>62:
envelope = feature.getDefaultGeometry().getEnvelope()
self.mapContext.getViewPort().setEnvelope(envelope)
envelope = feature.getDefaultGeometry().getEnvelope()
self.mapContext.getViewPort().setEnvelope(envelope)
setExpansionState(self.tree,es)
return
if isinstance(node.getUserObject(), DataLayer):
Expand Down Expand Up @@ -152,133 +151,136 @@ def mouseClicked(self, event):
menu.show(self.tree,x,y)

class SelectionCellRenderer(TreeCellRenderer):
def __init__(self,tree,mapContext):
self.tree = tree
self.mapContext = mapContext
self.lblGroup = JLabel()
self.lblGroup.setBackground(Color(222,227,233)) #.BLUE.brighter())
self.lblGroup.setOpaque(True)
self.lblGroup.setText("plddddddddddddddddddddddddddddddddddddddddddddddddddddddd")
self.lblGroupPreferredSize = self.lblGroup.getPreferredSize()
#self.lblGroupPreferredSize.setSize(30,200)#self.lblGroupPreferredSize.getHeight()+4, self.lblGroupPreferredSize.getWidth())
self.pnlLayer = JPanel()
self.pnlLayer.setOpaque(False)
def __init__(self,tree,mapContext):
self.tree = tree
self.mapContext = mapContext
self.lblGroup = JLabel()
self.lblGroup.setBackground(Color(222,227,233)) #.BLUE.brighter())
self.lblGroup.setOpaque(True)
self.lblGroup.setText("plddddddddddddddddddddddddddddddddddddddddddddddddddddddd")

self.lblGroupPreferredSize = self.lblGroup.getPreferredSize()
#h = self.lblGroupPreferredSize.getHeight()
#w = self.lblGroupPreferredSize.getWidth()
#self.lblGroupPreferredSize.setSize(h, w)
self.pnlLayer = JPanel()
self.pnlLayer.setOpaque(False)

self.pnlLayer.setLayout(FlowLayout(FlowLayout.LEFT))
self.pnlLayer.setLayout(FlowLayout(FlowLayout.LEFT))

self.lblClean = JLabel()
self.lblClean = JLabel()

self.chkLayerVisibility = JCheckBox()
self.chkLayerVisibility.setOpaque(False)
self.lblLayerName = JLabel()
self.lblLayerIcon = JLabel()
self.lblFeatureSelecteds = JLabel()
self.chkLayerVisibility = JCheckBox()
self.chkLayerVisibility.setOpaque(False)
self.lblLayerName = JLabel()
self.lblLayerIcon = JLabel()
self.lblFeatureSelecteds = JLabel()

self.pnlLayer.add(self.chkLayerVisibility)
self.pnlLayer.add(self.lblClean)
self.pnlLayer.add(self.lblFeatureSelecteds)
self.pnlLayer.add(self.lblLayerIcon)
self.pnlLayer.add(self.lblLayerName)
self.tree.setRowHeight(int(self.pnlLayer.getPreferredSize().getHeight()))
self.lblUnknown = JLabel()
self.pnlLayer.add(self.chkLayerVisibility)
self.pnlLayer.add(self.lblClean)
self.pnlLayer.add(self.lblFeatureSelecteds)
self.pnlLayer.add(self.lblLayerIcon)
self.pnlLayer.add(self.lblLayerName)
self.tree.setRowHeight(int(self.pnlLayer.getPreferredSize().getHeight())-3)
self.lblUnknown = JLabel()

## Feature
self.lblFeatureIcon = JLabel()
self.lblFeatureName = JLabel()
i18n = ToolsLocator.getI18nManager()
self.lblFeatureName.setText(i18n.getTranslation("_Feature"))
self.pnlFeature = JPanel()
self.pnlFeature.setOpaque(False)
self.pnlFeature.setLayout(FlowLayout(FlowLayout.LEFT))
self.pnlFeature.add(self.lblFeatureIcon)
self.pnlFeature.add(self.lblFeatureName)
def getTreeCellRendererComponent(self, tree, value, selected, expanded, leaf, row, hasFocus):
uo = value.getUserObject()
if isinstance(uo, DataGroup):
text = "[" + str(value.getChildCount()) +"] " + uo.getName()
self.lblGroup.setText(text)
self.lblGroup.setPreferredSize(self.lblGroupPreferredSize)
return self.lblGroup
if isinstance(uo, DataLayer):
layer = uo.getLayer()
## Feature
self.lblFeatureIcon = JLabel()
self.lblFeatureName = JLabel()
i18n = ToolsLocator.getI18nManager()
self.lblFeatureName.setText(i18n.getTranslation("_Feature"))
self.pnlFeature = JPanel()
self.pnlFeature.setOpaque(False)
self.pnlFeature.setLayout(FlowLayout(FlowLayout.LEFT))
self.pnlFeature.add(self.lblFeatureIcon)
self.pnlFeature.add(self.lblFeatureName)

def getTreeCellRendererComponent(self, tree, value, selected, expanded, leaf, row, hasFocus):
uo = value.getUserObject()
if isinstance(uo, DataGroup):
text = "[" + str(value.getChildCount()) +"] " + uo.getName()
self.lblGroup.setText(text)
self.lblGroup.setPreferredSize(self.lblGroupPreferredSize)
return self.lblGroup
if isinstance(uo, DataLayer):
layer = uo.getLayer()

self.lblLayerName.setText(uo.getName())
self.lblLayerIcon.setIcon(getIconFromLayer(layer))
if layer.isVisible():
self.lblLayerName.setEnabled(True)
else:
self.lblLayerName.setEnabled(False)
self.lblClean.setIcon(getIconByName("edit-clear"))
self.chkLayerVisibility.setSelected(layer.isVisible())
if layer.isWithinScale(self.mapContext.getScaleView()): # and layer.isVisible():
self.chkLayerVisibility.setEnabled(True)
else:
self.chkLayerVisibility.setEnabled(False)
if layer.getDataStore() != None and layer.getDataStore().getSelection()!= None and layer.getDataStore().getSelection().getSize() !=0: # and layer.isVisible():
self.lblClean.setEnabled(True)
self.lblFeatureSelecteds.setText(str(layer.getDataStore().getSelection().getSize()))
self.lblFeatureSelecteds.setEnabled(True)
else:
self.lblClean.setEnabled(False)
self.lblFeatureSelecteds.setText("0")
self.lblFeatureSelecteds.setEnabled(False)
font = self.lblLayerName.getFont()
self.lblLayerName.setForeground(Color.BLACK)
if layer.isEditing():
self.lblLayerName.setForeground(Color.RED)
#if layer.isActive():
if layer.isActive(): # and not font.isBold():
newfont = font.deriveFont(Font.BOLD)
self.lblLayerName.setFont(newfont)
else:
newfont = font.deriveFont(Font.PLAIN)
self.lblLayerName.setFont(newfont)
self.lblLayerName.setText(uo.getName())
self.lblLayerIcon.setIcon(getIconFromLayer(layer))
if layer.isVisible():
self.lblLayerName.setEnabled(True)
else:
self.lblLayerName.setEnabled(False)
self.lblClean.setIcon(getIconByName("edit-clear"))
self.chkLayerVisibility.setSelected(layer.isVisible())
if layer.isWithinScale(self.mapContext.getScaleView()): # and layer.isVisible():
self.chkLayerVisibility.setEnabled(True)
else:
self.chkLayerVisibility.setEnabled(False)
if layer.getDataStore() != None and layer.getDataStore().getSelection()!= None and layer.getDataStore().getSelection().getSize() !=0: # and layer.isVisible():
self.lblClean.setEnabled(True)
self.lblFeatureSelecteds.setText(str(layer.getDataStore().getSelection().getSize()))
self.lblFeatureSelecteds.setEnabled(True)
else:
self.lblClean.setEnabled(False)
self.lblFeatureSelecteds.setText("0")
self.lblFeatureSelecteds.setEnabled(False)

font = self.lblLayerName.getFont()
self.lblLayerName.setForeground(Color.BLACK)
if layer.isEditing():
self.lblLayerName.setForeground(Color.RED)
#if layer.isActive():
if layer.isActive(): # and not font.isBold():
newfont = font.deriveFont(Font.BOLD)
self.lblLayerName.setFont(newfont)
else:
newfont = font.deriveFont(Font.PLAIN)
self.lblLayerName.setFont(newfont)

return self.pnlLayer
if isinstance(uo, FeatureDataLayerNode):
self.lblFeatureName.setText(uo.getFeature().toString())
self.lblFeatureIcon.setIcon(getIconByName("edit-clear"))
return self.pnlFeature
self.lblUnknown.setText("")
self.lblUnknown.setPreferredSize(Dimension(0,0))
return self.lblUnknown
return self.pnlLayer
if isinstance(uo, FeatureDataLayerNode):
self.lblFeatureName.setText(uo.getFeature().toString())
self.lblFeatureIcon.setIcon(getIconByName("edit-clear"))

return self.pnlFeature
self.lblUnknown.setText("")
self.lblUnknown.setPreferredSize(Dimension(0,0))
return self.lblUnknown


def createTreeModel(mapContext, reducedTree=True):
i18n = ToolsLocator.getI18nManager()
root = DefaultMutableTreeNode(i18n.getTranslation("_Selection"))
rootSelected = DefaultMutableTreeNode(DataGroup(i18n.getTranslation("_Selected")))
rootSelectable = DefaultMutableTreeNode(DataGroup(i18n.getTranslation("_Selectable")))
rootNotSelectable = DefaultMutableTreeNode(DataGroup(i18n.getTranslation("_Not_selectable")))
root.insert(rootSelected, root.getChildCount())
root.insert(rootSelectable, root.getChildCount())
root.insert(rootNotSelectable, root.getChildCount())
i18n = ToolsLocator.getI18nManager()

root = DefaultMutableTreeNode(i18n.getTranslation("_Selection"))

rootSelected = DefaultMutableTreeNode(DataGroup(i18n.getTranslation("_Selected")))
rootSelectable = DefaultMutableTreeNode(DataGroup(i18n.getTranslation("_Selectable")))
rootNotSelectable = DefaultMutableTreeNode(DataGroup(i18n.getTranslation("_Not_selectable")))

root.insert(rootSelected, root.getChildCount())
root.insert(rootSelectable, root.getChildCount())
root.insert(rootNotSelectable, root.getChildCount())

for layer in iter(mapContext.deepiterator()):
store = layer.getDataStore()
if isinstance(store,DefaultFeatureStore) and store.getSelection().getSize() != 0:
newNode = DefaultMutableTreeNode(DataLayer(layer.getName(),layer))
for layer in iter(mapContext.deepiterator()):
store = layer.getDataStore()
if isinstance(store,DefaultFeatureStore) and store.getSelection().getSize() != 0:
newNode = DefaultMutableTreeNode(DataLayer(layer.getName(),layer))

fset = layer.getDataStore().getSelection()
for f in fset:
newFeature = DefaultMutableTreeNode(FeatureDataLayerNode(layer.getName(),layer,f))
newNode.insert(newFeature, newNode.getChildCount())
rootSelected.insert(newNode, 0)
elif isinstance(store,DefaultFeatureStore):
newNode = DefaultMutableTreeNode(DataLayer(layer.getName(),layer))
rootSelectable.insert(newNode,0)
else:
newNode = DefaultMutableTreeNode(DataLayer(layer.getName(),layer))
rootNotSelectable.insert(newNode,0)
model = DefaultTreeModel(root)
return model
fset = layer.getDataStore().getSelection()
for f in fset:
newFeature = DefaultMutableTreeNode(FeatureDataLayerNode(layer.getName(),layer,f))
newNode.insert(newFeature, newNode.getChildCount())
rootSelected.insert(newNode, 0)
elif isinstance(store,DefaultFeatureStore):
newNode = DefaultMutableTreeNode(DataLayer(layer.getName(),layer))
rootSelectable.insert(newNode,0)
else:
newNode = DefaultMutableTreeNode(DataLayer(layer.getName(),layer))
rootNotSelectable.insert(newNode,0)

model = DefaultTreeModel(root)
return model

class DataFolder(object):
def __init__(self,name, path, icon=None):
Expand Down
2 changes: 0 additions & 2 deletions sourceorder.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ def __init__(self,tree,mapContext):
self.mapContext = mapContext

def mouseClicked(self, event):

x = event.getX()
y = event.getY()
row = self.tree.getRowForLocation(x,y)
Expand Down Expand Up @@ -129,7 +128,6 @@ def __init__(self,tree,mapContext):
self.lblFolder.setText("plddddddddddddddddddddddddddddddddddddddddddddddddddddddd")

### Folder

self.pnlFolder = JPanel()
self.pnlFolder.setOpaque(False)
self.pnlFolder.setLayout(FlowLayout(FlowLayout.LEFT))
Expand Down
Loading

0 comments on commit 55afc67

Please sign in to comment.