-
-
Notifications
You must be signed in to change notification settings - Fork 268
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Property Sections] Refactor multi-composite sections
- Refactor into AbstractMultiControlSection - Don't show a control if the multi-selection contains an object that is not valid - This is how it works for Sections with one control
- Loading branch information
Showing
3 changed files
with
74 additions
and
50 deletions.
There are no files selected for viewing
66 changes: 66 additions & 0 deletions
66
...ool.editor/src/com/archimatetool/editor/propertysections/AbstractMultiControlSection.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
/** | ||
* This program and the accompanying materials | ||
* are made available under the terms of the License | ||
* which accompanies this distribution in the file LICENSE.txt | ||
*/ | ||
package com.archimatetool.editor.propertysections; | ||
|
||
import org.eclipse.swt.layout.GridLayout; | ||
import org.eclipse.swt.widgets.Composite; | ||
|
||
import com.archimatetool.model.IArchimateModelObject; | ||
|
||
|
||
|
||
/** | ||
* Abstract Property Section that contains two or more controls that update and layout according to the selection | ||
* | ||
* @author Phillip Beauvoir | ||
*/ | ||
public abstract class AbstractMultiControlSection extends AbstractECorePropertySection { | ||
|
||
protected Composite parentComposite; | ||
protected GridLayoutColumnHandler columnHandler; | ||
|
||
/** | ||
* Create controls and set number of columns | ||
* @param parent | ||
* @param numColumns | ||
*/ | ||
protected void init(Composite parent, int numColumns) { | ||
parentComposite = parent; | ||
((GridLayout)parent.getLayout()).horizontalSpacing = 30; | ||
columnHandler = GridLayoutColumnHandler.create(parentComposite, numColumns); | ||
} | ||
|
||
/** | ||
* @param featureName | ||
* @return true if a control shouldbe shown according to its feature | ||
*/ | ||
protected boolean shouldShowControl(String featureName) { | ||
for(IArchimateModelObject object : getEObjects()) { | ||
if(!getFilter().shouldExposeFeature(object, featureName)) { | ||
return false; | ||
} | ||
} | ||
return true; | ||
} | ||
|
||
/** | ||
* Layout controls | ||
*/ | ||
protected void layout() { | ||
if(columnHandler != null) { | ||
columnHandler.updateColumns(); | ||
} | ||
|
||
parentComposite.requestLayout(); | ||
} | ||
|
||
@Override | ||
public void dispose() { | ||
super.dispose(); | ||
columnHandler = null; | ||
parentComposite = null; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters