Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
K
kernel
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
af3
kernel
Commits
361e745a
Commit
361e745a
authored
13 years ago
by
Dongyue Mou
Browse files
Options
Downloads
Patches
Plain Diff
bug partially fixed
refs 394
parent
ec7bd9ea
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
org.fortiss.tooling.base.ui/trunk/src/org/fortiss/tooling/base/ui/dialog/ElementTreeSingleSelectDialog.java
+55
-87
55 additions, 87 deletions
...tooling/base/ui/dialog/ElementTreeSingleSelectDialog.java
with
55 additions
and
87 deletions
org.fortiss.tooling.base.ui/trunk/src/org/fortiss/tooling/base/ui/dialog/ElementTreeSingleSelectDialog.java
+
55
−
87
View file @
361e745a
...
...
@@ -17,9 +17,7 @@ $Id$
+--------------------------------------------------------------------------*/
package
org.fortiss.tooling.base.ui.dialog
;
import
static
org
.
eclipse
.
jface
.
dialogs
.
IDialogConstants
.
CANCEL_ID
;
import
static
org
.
eclipse
.
jface
.
dialogs
.
IDialogConstants
.
OK_ID
;
import
static
org
.
eclipse
.
jface
.
dialogs
.
IDialogConstants
.
OK_LABEL
;
import
java.util.ArrayList
;
import
java.util.LinkedList
;
...
...
@@ -34,7 +32,6 @@ import org.eclipse.jface.viewers.ITreeSelection;
import
org.eclipse.jface.viewers.SelectionChangedEvent
;
import
org.eclipse.jface.viewers.TreePath
;
import
org.eclipse.jface.viewers.TreeSelection
;
import
org.eclipse.jface.viewers.TreeViewer
;
import
org.eclipse.swt.SWT
;
import
org.eclipse.swt.events.SelectionAdapter
;
import
org.eclipse.swt.events.SelectionEvent
;
...
...
@@ -52,7 +49,7 @@ import org.eclipse.swt.widgets.Shell;
* @author mou
* @author $Author$
* @version $Rev$
* @ConQAT.Rating
GREEN
Hash:
1F1AEE709062AF84FC45A41E95D67DBD
* @ConQAT.Rating
YELLOW
Hash:
21390B2073FFC2212901CC3D583D88DA
*/
public
class
ElementTreeSingleSelectDialog
extends
TitleAreaDialog
{
...
...
@@ -71,24 +68,8 @@ public class ElementTreeSingleSelectDialog extends TitleAreaDialog {
/** the label provider */
private
ILabelProvider
labelSupport
;
/** the main tree viewer */
private
TreeViewer
elementTreeViewer
;
/**
* Default Constructor for GUI builder.
*
* @param parentShell
*
* @deprecated
* @wbp.parser.constructor
*/
@Deprecated
public
ElementTreeSingleSelectDialog
(
Shell
parentShell
)
{
super
(
parentShell
);
setShellStyle
(
SWT
.
SHELL_TRIM
);
setErrorMessage
(
""
);
setHelpAvailable
(
false
);
}
/** The gui composite */
private
ElementTreeSingleSelectDialogGUI
gui
;
/**
* Main constructor
...
...
@@ -117,23 +98,20 @@ public class ElementTreeSingleSelectDialog extends TitleAreaDialog {
rootElements
=
new
ArrayList
<
Object
>(
roots
);
}
dialogEditSupport
=
edit
;
contentSupport
=
contentProvider
;
labelSupport
=
labelProvider
;
if
(
selected
==
null
)
{
selectedPath
=
null
;
}
else
{
selectedPath
=
computeTreePath
(
rootElements
,
selected
);
}
dialogEditSupport
=
edit
;
contentSupport
=
contentProvider
;
labelSupport
=
labelProvider
;
}
/** {@inheritDoc} */
@Override
protected
Control
createDialogArea
(
Composite
parent
)
{
// CAUTION: The code below is automatically generated, do not edit
// manually!
setHelpAvailable
(
false
);
setTitle
(
"Select"
);
...
...
@@ -141,30 +119,45 @@ public class ElementTreeSingleSelectDialog extends TitleAreaDialog {
// create controls
Composite
area
=
(
Composite
)
super
.
createDialogArea
(
parent
);
ElementTreeSingleSelectDialogGUI
container
=
new
ElementTreeSingleSelectDialogGUI
(
area
,
SWT
.
NONE
);
container
.
setLayoutData
(
new
GridData
(
GridData
.
FILL_BOTH
));
gui
=
new
ElementTreeSingleSelectDialogGUI
(
area
,
SWT
.
NONE
);
gui
.
setLayoutData
(
new
GridData
(
GridData
.
FILL_BOTH
));
// hide edit toolbar if no edit function is available
if
(
dialogEditSupport
==
null
)
{
gui
.
getLeftToolBar
().
setVisible
(
false
);
((
GridData
)
gui
.
getLeftToolBar
().
getLayoutData
()).
exclude
=
true
;
}
// label, content and input
gui
.
getElementTreeViewer
().
setLabelProvider
(
labelSupport
);
gui
.
getElementTreeViewer
().
setContentProvider
(
new
MultiRootTreeContentProvider
(
rootElements
,
contentSupport
));
gui
.
getElementTreeViewer
().
setInput
(
rootElements
);
if
(
selectedPath
!=
null
)
gui
.
getElementTreeViewer
().
setSelection
(
new
TreeSelection
(
selectedPath
),
true
);
// create listeners
container
.
getCreateButton
().
addSelectionListener
(
new
SelectionAdapter
()
{
/** {@inheritDoc} */
@Override
public
void
widgetSelected
(
SelectionEvent
e
)
{
createElement
();
}
});
gui
.
getCreateButton
().
addSelectionListener
(
new
SelectionAdapter
()
{
/** {@inheritDoc} */
@Override
public
void
widgetSelected
(
SelectionEvent
e
)
{
createElement
();
}
});
container
.
getDeleteButton
().
addSelectionListener
(
new
SelectionAdapter
()
{
/** {@inheritDoc} */
@Override
public
void
widgetSelected
(
SelectionEvent
e
)
{
deleteElement
();
}
});
gui
.
getDeleteButton
().
addSelectionListener
(
new
SelectionAdapter
()
{
/** {@inheritDoc} */
@Override
public
void
widgetSelected
(
SelectionEvent
e
)
{
deleteElement
();
}
});
container
.
getEditButton
().
addSelectionListener
(
new
SelectionAdapter
()
{
gui
.
getEditButton
().
addSelectionListener
(
new
SelectionAdapter
()
{
/** {@inheritDoc} */
@Override
public
void
widgetSelected
(
SelectionEvent
e
)
{
...
...
@@ -172,42 +165,17 @@ public class ElementTreeSingleSelectDialog extends TitleAreaDialog {
}
});
e
lementTreeViewer
.
addSelectionChangedListener
(
new
ISelectionChangedListener
()
{
gui
.
getE
lementTreeViewer
().
addPostSelectionChangedListener
(
new
ISelectionChangedListener
()
{
@Override
public
void
selectionChanged
(
SelectionChangedEvent
event
)
{
selectElement
();
}
});
// label, content and input
elementTreeViewer
.
setLabelProvider
(
labelSupport
);
elementTreeViewer
.
setContentProvider
(
new
MultiRootTreeContentProvider
(
rootElements
,
contentSupport
));
elementTreeViewer
.
setInput
(
rootElements
);
if
(
selectedPath
!=
null
)
elementTreeViewer
.
setSelection
(
new
TreeSelection
(
selectedPath
),
true
);
// hide edit toolbar if no edit function is available
if
(
dialogEditSupport
==
null
)
{
container
.
getLeftToolBar
().
setVisible
(
false
);
((
GridData
)
container
.
getLeftToolBar
().
getLayoutData
()).
exclude
=
true
;
}
return
area
;
}
/** {@inheritDoc} */
@Override
protected
void
createButtonsForButtonBar
(
Composite
parent
)
{
createButton
(
parent
,
OK_ID
,
OK_LABEL
,
false
);
createButton
(
parent
,
CANCEL_ID
,
"Cancel"
,
true
);
}
/** {@inheritDoc} */
@Override
protected
Point
getInitialSize
()
{
...
...
@@ -249,8 +217,8 @@ public class ElementTreeSingleSelectDialog extends TitleAreaDialog {
try
{
// find the path to hold the new element
ITreeSelection
selection
=
(
ITreeSelection
)
elementTreeViewer
.
getSelection
();
ITreeSelection
selection
=
(
ITreeSelection
)
gui
.
getElementTreeViewer
()
.
getSelection
();
if
(
selection
.
getPaths
()
!=
null
&&
selection
.
getPaths
().
length
!=
1
)
return
;
// at most 1 element can be selected
...
...
@@ -275,8 +243,8 @@ public class ElementTreeSingleSelectDialog extends TitleAreaDialog {
}
// insert the new element
e
lementTreeViewer
.
add
(
path
,
o
);
e
lementTreeViewer
.
reveal
(
o
);
gui
.
getE
lementTreeViewer
()
.
add
(
path
,
o
);
gui
.
getE
lementTreeViewer
()
.
reveal
(
o
);
}
catch
(
Exception
e2
)
{
e2
.
printStackTrace
();
}
...
...
@@ -288,8 +256,8 @@ public class ElementTreeSingleSelectDialog extends TitleAreaDialog {
return
;
try
{
ITreeSelection
selection
=
(
ITreeSelection
)
elementTreeViewer
.
getSelection
();
ITreeSelection
selection
=
(
ITreeSelection
)
gui
.
getElementTreeViewer
()
.
getSelection
();
if
(
selection
.
getPaths
()
==
null
)
return
;
...
...
@@ -299,7 +267,7 @@ public class ElementTreeSingleSelectDialog extends TitleAreaDialog {
if
(
rootElements
.
contains
(
path
.
getLastSegment
()))
rootElements
.
remove
(
path
.
getLastSegment
());
e
lementTreeViewer
.
remove
(
path
);
gui
.
getE
lementTreeViewer
()
.
remove
(
path
);
if
(
path
.
equals
(
selectedPath
))
{
selectedPath
=
null
;
...
...
@@ -318,8 +286,8 @@ public class ElementTreeSingleSelectDialog extends TitleAreaDialog {
try
{
// find the path to the element
ITreeSelection
selection
=
(
ITreeSelection
)
elementTreeViewer
.
getSelection
();
ITreeSelection
selection
=
(
ITreeSelection
)
gui
.
getElementTreeViewer
()
.
getSelection
();
if
(
selection
.
getPaths
()
==
null
||
selection
.
getPaths
().
length
!=
1
)
return
;
// 1 element must be selected
...
...
@@ -327,7 +295,7 @@ public class ElementTreeSingleSelectDialog extends TitleAreaDialog {
TreePath
path
=
selection
.
getPaths
()[
0
];
dialogEditSupport
.
editElement
(
path
.
getLastSegment
());
e
lementTreeViewer
.
refresh
();
gui
.
getE
lementTreeViewer
()
.
refresh
();
}
catch
(
Exception
e2
)
{
e2
.
printStackTrace
();
}
...
...
@@ -336,7 +304,7 @@ public class ElementTreeSingleSelectDialog extends TitleAreaDialog {
/** update the selected element by its tree path */
private
void
selectElement
()
{
// find the path to the element
ITreeSelection
selection
=
(
ITreeSelection
)
e
lementTreeViewer
ITreeSelection
selection
=
(
ITreeSelection
)
gui
.
getE
lementTreeViewer
()
.
getSelection
();
if
(
selection
.
getPaths
()
==
null
||
selection
.
getPaths
().
length
!=
1
)
{
selectedPath
=
null
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment