-
-
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.
- Loading branch information
Showing
11 changed files
with
256 additions
and
0 deletions.
There are no files selected for viewing
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
24 changes: 24 additions & 0 deletions
24
...tor/src/com/archimatetool/editor/diagram/commands/DiagramModelObjectLineStyleCommand.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,24 @@ | ||
/** | ||
* 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.diagram.commands; | ||
|
||
import com.archimatetool.editor.model.commands.FeatureCommand; | ||
import com.archimatetool.model.IDiagramModelObject; | ||
|
||
|
||
|
||
/** | ||
* Line Style Command | ||
* | ||
* @author Phillip Beauvoir | ||
*/ | ||
public class DiagramModelObjectLineStyleCommand extends FeatureCommand { | ||
|
||
public DiagramModelObjectLineStyleCommand(IDiagramModelObject object, int style) { | ||
super("Change Line Style", object, | ||
IDiagramModelObject.FEATURE_LINE_STYLE, style, IDiagramModelObject.FEATURE_LINE_STYLE_DEFAULT); | ||
} | ||
} |
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
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
150 changes: 150 additions & 0 deletions
150
...l.editor/src/com/archimatetool/editor/propertysections/DiagramObjectLineStyleSection.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,150 @@ | ||
/** | ||
* 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 static org.eclipse.swt.events.SelectionListener.widgetSelectedAdapter; | ||
|
||
import org.eclipse.emf.common.notify.Notification; | ||
import org.eclipse.emf.ecore.EObject; | ||
import org.eclipse.gef.commands.Command; | ||
import org.eclipse.gef.commands.CompoundCommand; | ||
import org.eclipse.jface.action.Action; | ||
import org.eclipse.jface.action.IAction; | ||
import org.eclipse.jface.action.MenuManager; | ||
import org.eclipse.jface.resource.ImageDescriptor; | ||
import org.eclipse.swt.SWT; | ||
import org.eclipse.swt.graphics.Point; | ||
import org.eclipse.swt.graphics.Rectangle; | ||
import org.eclipse.swt.widgets.Button; | ||
import org.eclipse.swt.widgets.Composite; | ||
import org.eclipse.swt.widgets.Menu; | ||
import org.eclipse.ui.PlatformUI; | ||
|
||
import com.archimatetool.editor.diagram.commands.DiagramModelObjectLineStyleCommand; | ||
import com.archimatetool.editor.ui.IArchiImages; | ||
import com.archimatetool.model.IArchimatePackage; | ||
import com.archimatetool.model.IDiagramModelObject; | ||
|
||
|
||
|
||
/** | ||
* Diagram Object Line Style Property Section | ||
* | ||
* @author Phillip Beauvoir | ||
*/ | ||
public class DiagramObjectLineStyleSection extends AbstractECorePropertySection { | ||
|
||
private static final String HELP_ID = "com.archimatetool.help.elementPropertySection"; //$NON-NLS-1$ | ||
|
||
/** | ||
* Filter to show or reject this section depending on input value | ||
*/ | ||
public static class Filter extends ObjectFilter { | ||
@Override | ||
public boolean isRequiredType(Object object) { | ||
return object instanceof IDiagramModelObject dmo && shouldExposeFeature(dmo, IDiagramModelObject.FEATURE_LINE_STYLE); | ||
} | ||
|
||
@Override | ||
public Class<?> getAdaptableType() { | ||
return IDiagramModelObject.class; | ||
} | ||
} | ||
|
||
private Button button; | ||
|
||
@Override | ||
protected void createControls(Composite parent) { | ||
createLabel(parent, "Line Style:", ITabbedLayoutConstants.STANDARD_LABEL_WIDTH, SWT.CENTER); | ||
|
||
button = getWidgetFactory().createButton(parent, null, SWT.PUSH); | ||
|
||
button.addSelectionListener(widgetSelectedAdapter(event -> { | ||
MenuManager menuManager = new MenuManager(); | ||
|
||
menuManager.add(createAction("Solid", 0, IArchiImages.ImageFactory.getImageDescriptor(IArchiImages.LINE_SOLID))); | ||
menuManager.add(createAction("Dashed", 1, IArchiImages.ImageFactory.getImageDescriptor(IArchiImages.LINE_DASHED))); | ||
menuManager.add(createAction("Dotted", 2, IArchiImages.ImageFactory.getImageDescriptor(IArchiImages.LINE_DOTTED))); | ||
|
||
Menu menu = menuManager.createContextMenu(button.getShell()); | ||
Rectangle buttonBounds = button.getBounds(); | ||
Point p = button.getParent().toDisplay(buttonBounds.x, buttonBounds.y + buttonBounds.height); | ||
menu.setLocation(p); | ||
menu.setVisible(true); | ||
})); | ||
|
||
// Help ID | ||
PlatformUI.getWorkbench().getHelpSystem().setHelp(parent, HELP_ID); | ||
} | ||
|
||
private IAction createAction(String text, final int value, final ImageDescriptor imageDesc) { | ||
IAction action = new Action(text, IAction.AS_RADIO_BUTTON) { | ||
@Override | ||
public void run() { | ||
CompoundCommand result = new CompoundCommand(); | ||
|
||
for(EObject object : getEObjects()) { | ||
if(isAlive(object)) { | ||
Command cmd = new DiagramModelObjectLineStyleCommand((IDiagramModelObject)object, value); | ||
if(cmd.canExecute()) { | ||
result.add(cmd); | ||
} | ||
} | ||
} | ||
|
||
executeCommand(result.unwrap()); | ||
} | ||
|
||
@Override | ||
public ImageDescriptor getImageDescriptor() { | ||
return imageDesc; | ||
} | ||
}; | ||
|
||
action.setChecked(((IDiagramModelObject)getFirstSelectedObject()).getLineStyle() == value); | ||
|
||
return action; | ||
} | ||
|
||
|
||
@Override | ||
protected void notifyChanged(Notification msg) { | ||
if(msg.getNotifier() == getFirstSelectedObject()) { | ||
Object feature = msg.getFeature(); | ||
|
||
if(isFeatureNotification(msg, IDiagramModelObject.FEATURE_LINE_STYLE) || | ||
feature == IArchimatePackage.Literals.LOCKABLE__LOCKED) { | ||
update(); | ||
} | ||
} | ||
} | ||
|
||
@Override | ||
protected void update() { | ||
int lineStyle = ((IDiagramModelObject)getFirstSelectedObject()).getLineStyle(); | ||
|
||
switch(lineStyle) { | ||
case 0: | ||
default: | ||
button.setImage(IArchiImages.ImageFactory.getImage(IArchiImages.LINE_SOLID)); | ||
break; | ||
case 1: | ||
button.setImage(IArchiImages.ImageFactory.getImage(IArchiImages.LINE_DASHED)); | ||
break; | ||
case 2: | ||
button.setImage(IArchiImages.ImageFactory.getImage(IArchiImages.LINE_DOTTED)); | ||
break; | ||
} | ||
|
||
boolean enabled = !isLocked(getFirstSelectedObject()); | ||
button.setEnabled(enabled); | ||
} | ||
|
||
@Override | ||
protected IObjectFilter getFilter() { | ||
return new Filter(); | ||
} | ||
} |
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
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