use of org.eclipse.gef.commands.CompoundCommand in project archi by archimatetool.
the class JunctionTypeSection method createControls.
@Override
protected void createControls(Composite parent) {
createLabel(parent, Messages.JunctionTypeSection_2, ITabbedLayoutConstants.STANDARD_LABEL_WIDTH, SWT.CENTER);
fComboType = new Combo(parent, SWT.READ_ONLY);
fComboType.setItems(fComboTypeItems);
fComboType.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
fComboType.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
CompoundCommand result = new CompoundCommand();
for (EObject junction : getEObjects()) {
if (isAlive(junction)) {
Command cmd = new EObjectFeatureCommand(Messages.JunctionTypeSection_3, junction, IArchimatePackage.Literals.JUNCTION__TYPE, fTypeValues[fComboType.getSelectionIndex()]);
if (cmd.canExecute()) {
result.add(cmd);
}
}
}
executeCommand(result.unwrap());
}
});
// Help ID
PlatformUI.getWorkbench().getHelpSystem().setHelp(parent, HELP_ID);
}
use of org.eclipse.gef.commands.CompoundCommand in project archi by archimatetool.
the class DiagramModelConnectionSection method createRouterTypeControl.
private void createRouterTypeControl(Composite parent) {
// Label
createLabel(parent, Messages.DiagramModelConnectionSection_0, ITabbedLayoutConstants.BIG_LABEL_WIDTH, SWT.CENTER);
// Combo
fComboRouterType = new Combo(parent, SWT.READ_ONLY);
fComboRouterType.setItems(comboItems);
fComboRouterType.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
CompoundCommand result = new CompoundCommand();
for (EObject dm : getEObjects()) {
if (isAlive(dm)) {
Command cmd = new ConnectionRouterTypeCommand((IDiagramModel) dm, ConnectionRouterAction.CONNECTION_ROUTER_TYPES.get(fComboRouterType.getSelectionIndex()));
if (cmd.canExecute()) {
result.add(cmd);
}
}
}
executeCommand(result.unwrap());
}
});
GridData gd = new GridData(SWT.NONE, SWT.NONE, true, false);
gd.minimumWidth = ITabbedLayoutConstants.COMBO_WIDTH;
fComboRouterType.setLayoutData(gd);
}
use of org.eclipse.gef.commands.CompoundCommand in project archi by archimatetool.
the class DiagramModelImageSection method setImage.
protected void setImage(Object selected) {
String path = null;
try {
// User selected a file
if (selected instanceof File) {
File file = (File) selected;
if (!file.exists() || !file.canRead()) {
return;
}
IArchiveManager archiveManager = (IArchiveManager) ((IAdapter) getFirstSelectedObject()).getAdapter(IArchiveManager.class);
path = archiveManager.addImageFromFile(file);
} else // User selected a Gallery image path
if (selected instanceof String) {
path = (String) selected;
} else // User selected nothing
{
return;
}
} catch (IOException ex) {
ex.printStackTrace();
MessageDialog.openError(getPart().getSite().getShell(), Messages.DiagramModelImageSection_5, Messages.DiagramModelImageSection_6);
return;
}
CompoundCommand result = new CompoundCommand();
for (EObject dmo : getEObjects()) {
if (isAlive(dmo)) {
Command cmd = new EObjectFeatureCommand(Messages.DiagramModelImageSection_7, dmo, IArchimatePackage.Literals.DIAGRAM_MODEL_IMAGE_PROVIDER__IMAGE_PATH, path);
if (cmd.canExecute()) {
result.add(cmd);
}
}
}
executeCommand(result.unwrap());
}
use of org.eclipse.gef.commands.CompoundCommand in project archi by archimatetool.
the class TextAlignmentSection method createControls.
@Override
protected void createControls(final Composite parent) {
SelectionAdapter adapter = new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
for (int i = 0; i < fAlignmentButtons.length; i++) {
// Select/deselects
fAlignmentButtons[i].setSelection(e.widget == fAlignmentButtons[i]);
// Command
if (fAlignmentButtons[i] == e.widget) {
int alignment = (Integer) fAlignmentButtons[i].getData();
CompoundCommand result = new CompoundCommand();
for (EObject textAlignment : getEObjects()) {
if (((ITextAlignment) textAlignment).getTextAlignment() != alignment && isAlive(textAlignment)) {
Command cmd = new TextAlignmentCommand((ITextAlignment) textAlignment, alignment);
if (cmd.canExecute()) {
result.add(cmd);
}
}
}
executeCommand(result.unwrap());
}
}
}
};
createLabel(parent, Messages.TextAlignmentSection_0, ITabbedLayoutConstants.STANDARD_LABEL_WIDTH, SWT.CENTER);
Composite client = createComposite(parent, 3);
for (int i = 0; i < fAlignmentButtons.length; i++) {
fAlignmentButtons[i] = new Button(client, SWT.TOGGLE | SWT.FLAT);
// Need to do it this way for Mac
getWidgetFactory().adapt(fAlignmentButtons[i], true, true);
fAlignmentButtons[i].addSelectionListener(adapter);
}
// Left Button
fAlignmentButtons[0].setImage(IArchiImages.ImageFactory.getImage(IArchiImages.ICON_ALIGN_TEXT_LEFT));
fAlignmentButtons[0].setData(ITextAlignment.TEXT_ALIGNMENT_LEFT);
// Center Button
fAlignmentButtons[1].setImage(IArchiImages.ImageFactory.getImage(IArchiImages.ICON_ALIGN_TEXT_CENTER));
fAlignmentButtons[1].setData(ITextAlignment.TEXT_ALIGNMENT_CENTER);
// Right Button
fAlignmentButtons[2].setImage(IArchiImages.ImageFactory.getImage(IArchiImages.ICON_ALIGN_TEXT_RIGHT));
fAlignmentButtons[2].setData(ITextAlignment.TEXT_ALIGNMENT_RIGHT);
// Help
PlatformUI.getWorkbench().getHelpSystem().setHelp(parent, HELP_ID);
}
use of org.eclipse.gef.commands.CompoundCommand in project archi by archimatetool.
the class TextContentSection method createControls.
@Override
protected void createControls(Composite parent) {
createLabel(parent, Messages.TextContentSection_0, ITabbedLayoutConstants.STANDARD_LABEL_WIDTH, SWT.NONE);
StyledTextControl styledTextControl = createStyledTextControl(parent, SWT.NONE);
fTextContentControl = new PropertySectionTextControl(styledTextControl.getControl(), IArchimatePackage.Literals.TEXT_CONTENT__CONTENT) {
@Override
protected void textChanged(String oldText, String newText) {
CompoundCommand result = new CompoundCommand();
for (EObject textContent : getEObjects()) {
if (isAlive(textContent)) {
Command cmd = new EObjectFeatureCommand(Messages.TextContentSection_1, textContent, IArchimatePackage.Literals.TEXT_CONTENT__CONTENT, newText);
if (cmd.canExecute()) {
result.add(cmd);
}
}
}
executeCommand(result.unwrap());
}
};
fTextContentControl.setHint(Messages.TextContentSection_2);
// Help
PlatformUI.getWorkbench().getHelpSystem().setHelp(fTextContentControl.getTextControl(), HELP_ID);
}
Aggregations