Commit 6c112e23 authored by Romain Bioteau's avatar Romain Bioteau
Browse files

STUDIO-808

parent 976914ea
......@@ -84,12 +84,11 @@ protected org.eclipse.gef.palette.PaletteRoot createPaletteRoot(org.eclipse.gef.
}
}
if(!alreadyExists){
standard.add(new org.eclipse.gef.palette.MarqueeToolEntry()) ;
standard.add(new org.bonitasoft.studio.common.gmf.tools.ZoomInToolEntry());
standard.add(new org.bonitasoft.studio.common.gmf.tools.ZoomOutToolEntry());
standard.add(new org.eclipse.gef.palette.PaletteSeparator());
standard.add(hSpace) ;
standard.add(vSpave) ;
standard.add(new org.eclipse.gef.palette.MarqueeToolEntry()) ;
standard.add(new org.bonitasoft.studio.common.gmf.tools.ZoomInToolEntry());
standard.add(new org.bonitasoft.studio.common.gmf.tools.ZoomOutToolEntry());
standard.add(hSpace) ;
standard.add(vSpave) ;
}
applyCustomizationsToPalette(root);
......@@ -214,9 +213,6 @@ protected void configureGraphicalViewer() {
«REM»allow to add context menu to the palette«ENDREM»
«EXPAND configurePaletteViewer»
«REM»customization of the palette«ENDREM»
«EXPAND createPartControl»
«REM»customization of the palette«ENDREM»
«EXPAND constructPaletteViewer»
......@@ -315,7 +311,7 @@ public void dispose() {
getDiagramGraphicalViewer().addDropTargetListener(new org.bonitasoft.studio.common.gmf.tools.PaletteToolTransferDropTargetListenerWithSelection(getGraphicalViewer()));
super.initializeGraphicalViewer();
getDiagramGraphicalViewer().setProperty(org.eclipse.gmf.runtime.diagram.ui.internal.properties.WorkspaceViewerProperties.GRIDLINECOLOR, 0);
getDiagramGraphicalViewer().setProperty(org.eclipse.gmf.runtime.diagram.ui.internal.properties.WorkspaceViewerProperties.GRIDLINESTYLE,SWT.LINE_SOLID);
getDiagramGraphicalViewer().setProperty(org.eclipse.gmf.runtime.diagram.ui.internal.properties.WorkspaceViewerProperties.GRIDLINESTYLE,org.eclipse.swt.SWT.LINE_SOLID);
if(org.eclipse.core.runtime.Platform.getOS().equals(org.eclipse.core.runtime.Platform.OS_MACOSX)){
getGraphicalViewer().setProperty(org.eclipse.gef.MouseWheelHandler.KeyGenerator.getKey(SWT.COMMAND), org.eclipse.gef.MouseWheelZoomHandler.SINGLETON);
}
......@@ -562,145 +558,6 @@ TODO: get it fixed in GMF-Runtime«ENDREM»
}
«ENDDEFINE»
«DEFINE createPartControl FOR gmfgen::GenEditorView-»
/**
* @generated BonitaSoft
*/
public void createPartControl(org.eclipse.swt.widgets.Composite parent) {
super.createPartControl(parent);
org.eclipse.gef.ui.palette.FlyoutPaletteComposite control = (org.eclipse.gef.ui.palette.FlyoutPaletteComposite) parent.getChildren()[0];
// the palette composite
final org.eclipse.swt.widgets.Composite paletteComposite = (org.eclipse.swt.widgets.Composite) control.getChildren()[1];
if(paletteComposite.getChildren().length>=3){
org.eclipse.swt.layout.GridLayout layout = new org.eclipse.swt.layout.GridLayout(2, false);
layout.horizontalSpacing = 0;
layout.verticalSpacing = 0;
layout.marginBottom = 0;
layout.marginTop = 0;
layout.marginHeight = 0;
layout.marginWidth = 0;
layout.marginLeft = 0;
layout.marginRight = 0;
paletteComposite.setLayout(layout);
org.eclipse.swt.widgets.Control title = paletteComposite.getChildren()[0];
title.setLayoutData(org.eclipse.jface.layout.GridDataFactory.fillDefaults().grab(true, true).span(3, 1).create());
title.setVisible(false);
final org.eclipse.swt.widgets.Control arrowButton = paletteComposite.getChildren()[1];
arrowButton.setLayoutData(org.eclipse.jface.layout.GridDataFactory.fillDefaults().hint(20, SWT.DEFAULT).create());
arrowButton.moveAbove(title);
// arrowButton.setVisible(false);
org.eclipse.swt.widgets.Control palette = paletteComposite.getChildren()[2];
palette.setLayoutData(org.eclipse.jface.layout.GridDataFactory.fillDefaults().grab(true, true).span(3, 1).create());
final org.eclipse.swt.widgets.Composite buttonComposite = new org.eclipse.swt.widgets.Composite(paletteComposite, SWT.NONE);
org.eclipse.swt.layout.GridLayout layoutButton = new org.eclipse.swt.layout.GridLayout(3, false);
layoutButton.horizontalSpacing = 0;
layoutButton.verticalSpacing = 0;
layoutButton.marginBottom = 0;
layoutButton.marginTop = 0;
layoutButton.marginHeight = 0;
layoutButton.marginWidth = 0;
layoutButton.marginLeft = 1;
layoutButton.marginRight = 0;
buttonComposite.setLayout(layoutButton);
buttonComposite.setLayoutData(org.eclipse.jface.layout.GridDataFactory.fillDefaults().grab(true,false).create());
buttonComposite.moveAbove(palette);
buttonComposite.addPaintListener(new org.eclipse.swt.events.PaintListener() {
public void paintControl(org.eclipse.swt.events.PaintEvent e) {
buttonComposite.layout(true);
}
});
title.moveBelow(palette);
int yHint = 25;
final org.eclipse.swt.widgets.Button onlyIcones = new org.eclipse.swt.widgets.Button(buttonComposite, org.eclipse.swt.SWT.TOGGLE | SWT.FLAT);
onlyIcones.setImage(org.bonitasoft.studio.pics.Pics.getImage(org.bonitasoft.studio.pics.PicsConstants.paletteIcones));
onlyIcones.setLayoutData(org.eclipse.jface.layout.GridDataFactory.fillDefaults().hint(org.eclipse.swt.SWT.DEFAULT, yHint).grab(true, false).create());
onlyIcones.setToolTipText(org.bonitasoft.studio.common.Messages.paletteTooltipOnlyIcone);
final org.eclipse.swt.widgets.Button simple = new org.eclipse.swt.widgets.Button(buttonComposite, org.eclipse.swt.SWT.TOGGLE | SWT.FLAT);
simple.setImage(org.bonitasoft.studio.pics.Pics.getImage(org.bonitasoft.studio.pics.PicsConstants.paletteSimple));
simple.setLayoutData(org.eclipse.jface.layout.GridDataFactory.fillDefaults().hint(org.eclipse.swt.SWT.DEFAULT, yHint).grab(true, false).create());
simple.setToolTipText(org.bonitasoft.studio.common.Messages.paletteTooltipSimple);
final org.eclipse.swt.widgets.Button full = new org.eclipse.swt.widgets.Button(buttonComposite, org.eclipse.swt.SWT.TOGGLE | SWT.FLAT);
full.setImage(org.bonitasoft.studio.pics.Pics.getImage(org.bonitasoft.studio.pics.PicsConstants.paletteFull));
full.setLayoutData(org.eclipse.jface.layout.GridDataFactory.fillDefaults().hint(org.eclipse.swt.SWT.DEFAULT, yHint).grab(true, false).create());
full.setToolTipText(org.bonitasoft.studio.common.Messages.paletteTooltipFull);
org.eclipse.swt.widgets.Listener listener = new org.eclipse.swt.widgets.Listener() {
public void handleEvent(org.eclipse.swt.widgets.Event e) {
org.eclipse.swt.widgets.Control[] children = buttonComposite.getChildren();
for (int i = 0; i < children.length; i++) {
org.eclipse.swt.widgets.Control child = children[i];
if (e.widget != child && child instanceof org.eclipse.swt.widgets.Button && (child.getStyle() & org.eclipse.swt.SWT.TOGGLE) != 0) {
((org.eclipse.swt.widgets.Button) child).setSelection(false);
}
}
((org.eclipse.swt.widgets.Button) e.widget).setSelection(true);
}
};
org.eclipse.swt.events.SelectionAdapter launchSwitch = new org.eclipse.swt.events.SelectionAdapter() {
@Override
public void widgetSelected(org.eclipse.swt.events.SelectionEvent e) {
org.eclipse.ui.handlers.IHandlerService handlerService = (org.eclipse.ui.handlers.IHandlerService) PlatformUI.getWorkbench().getService(org.eclipse.ui.handlers.IHandlerService.class);
org.eclipse.ui.commands.ICommandService commandService = (org.eclipse.ui.commands.ICommandService) PlatformUI.getWorkbench().getService(org.eclipse.ui.commands.ICommandService.class);
org.eclipse.core.commands.Command switchPalette = commandService.getCommand("org.bonitasoft.studio.application.switchPalette");
String value;
if(e.widget.equals(simple)){
value = "simple";//$NON-NLS-1$
}else if (e.widget.equals(full)){
value = "full";//$NON-NLS-1$
}else{
value = "icones";//$NON-NLS-1$
}
org.eclipse.core.commands.IParameter mode;
try {
mode = switchPalette.getParameter("org.bonitasoft.studio.application.switch.advanced");
org.eclipse.core.commands.Parameterization parm = new org.eclipse.core.commands.Parameterization(mode, value);
org.eclipse.core.commands.ParameterizedCommand parmCommand = new org.eclipse.core.commands.ParameterizedCommand(switchPalette, new org.eclipse.core.commands.Parameterization[] { parm });
handlerService.executeCommand(parmCommand, null);
} catch (java.lang.Exception e1) {
org.bonitasoft.studio.common.log.BonitaStudioLog.error(e1);
}
}
};
simple.addSelectionListener(launchSwitch);
onlyIcones.addSelectionListener(launchSwitch);
full.addSelectionListener(launchSwitch);
simple.addListener(org.eclipse.swt.SWT.Selection, listener);
onlyIcones.addListener(org.eclipse.swt.SWT.Selection, listener);
full.addListener(org.eclipse.swt.SWT.Selection, listener);
org.eclipse.gef.ui.palette.PaletteViewer paletteViewer = ((org.eclipse.gmf.runtime.diagram.ui.parts.DiagramEditDomain)getDiagramEditDomain()).getPaletteViewer();
if(paletteViewer.getPaletteViewerPreferences().getLayoutSetting() == org.eclipse.gef.ui.palette.PaletteViewerPreferences.LAYOUT_ICONS){
//icones mode
onlyIcones.setSelection(true);
} else {
org.eclipse.gef.palette.PaletteContainer container = (org.eclipse.gef.palette.PaletteContainer) root.getChildren().get(root.getChildren().size()-1);
for (java.lang.Object item : container.getChildren()) {
if (item instanceof org.eclipse.gef.palette.PaletteEntry) {
org.eclipse.gef.palette.PaletteEntry entry = (org.eclipse.gef.palette.PaletteEntry) item;
if(!entry.isVisible()){
simple.setSelection(true);
break;
}
}
}
if(!simple.getSelection()){
full.setSelection(true);
}
}
}
}
«ENDDEFINE»
«DEFINE configurePaletteViewer FOR gmfgen::GenEditorView-»
......@@ -753,7 +610,7 @@ TODO: get it fixed in GMF-Runtime«ENDREM»
* @generated BonitaSoft
*/
protected org.eclipse.gef.ui.palette.PaletteViewer constructPaletteViewer() {
final org.eclipse.gef.ui.palette.PaletteViewer constructPaletteViewer = super.constructPaletteViewer();
final org.bonitasoft.studio.common.diagram.palette.CustomMainPaletteViewer constructPaletteViewer = new org.bonitasoft.studio.common.diagram.palette.CustomMainPaletteViewer();
constructPaletteViewer.setPaletteViewerPreferences(processPref);
//add property change listener to refresh the items (the default one does not work anymore with an other key)
......@@ -788,6 +645,19 @@ TODO: get it fixed in GMF-Runtime«ENDREM»
processPref.addPropertyChangeListener(paletteChangeListener);
org.eclipse.jface.preference.IPreferenceStore store = org.eclipse.gef.internal.InternalGEFPlugin.getDefault().getPreferenceStore();
store.setDefault(org.eclipse.gef.ui.palette.PaletteViewerPreferences.PREFERENCE_LAYOUT + preferencesKey, org.eclipse.gef.ui.palette.PaletteViewerPreferences.LAYOUT_ICONS);
final org.bonitasoft.studio.common.diagram.palette.CustomToolPaletteViewer toolPaletteViewer = new org.bonitasoft.studio.common.diagram.palette.CustomToolPaletteViewer();
toolPaletteViewer.showOnlyPaletteEntry("standardGroup");
toolPaletteViewer.setPaletteRoot(root);
toolPaletteViewer.setMainPaletteViewer(constructPaletteViewer);
constructPaletteViewer.setToolPaletteViewer(toolPaletteViewer);
getRulerComposite().setLayout(org.eclipse.jface.layout.GridLayoutFactory.fillDefaults().numColumns(1).margins(0, 0).spacing(0, 0).create());
getRulerComposite().getChildren()[0].setLayoutData(org.eclipse.jface.layout.GridDataFactory.fillDefaults().grab(true, true).create());
org.eclipse.swt.widgets.Control paletteControl = toolPaletteViewer.createControl(getRulerComposite());
paletteControl.setLayoutData(org.eclipse.jface.layout.GridDataFactory.fillDefaults().grab(true, false).create());
getRulerComposite().layout(true,true);
return constructPaletteViewer;
}
«ENDDEFINE»
......
......@@ -6668,7 +6668,7 @@
</compartments>
<palette>
<groups
title="Containers"
title="Swimlanes"
description=""
stack="true"
collapse="true">
......@@ -6704,7 +6704,7 @@
genNodes="//@diagram/@childNodes.39 //@diagram/@topLevelNodes.11"/>
</groups>
<groups
title="Transition"
title="Flow"
stack="true"
collapse="true">
<entries
......
......@@ -4,11 +4,11 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:gmftool="http://www.eclipse.org/gmf/2005/ToolDefinition">
<palette
title="BpmnPalette"
title="BPMN Palette"
description="">
<tools
xsi:type="gmftool:ToolGroup"
title="Containers"
title="Swimlanes"
description=""
collapsible="true"
stack="true">
......@@ -41,7 +41,7 @@
</tools>
<tools
xsi:type="gmftool:ToolGroup"
title="Transition"
title="Flow"
collapsible="true"
stack="true">
<tools
......
......@@ -32,6 +32,7 @@ Require-Bundle: org.eclipse.gmf.runtime.lite.svg;bundle-version="1.0.0",
org.eclipse.gmf.runtime.draw2d.ui.render;bundle-version="1.4.1",
org.eclipse.gmf.runtime.draw2d.ui.render.awt;bundle-version="1.4.1"
Export-Package: org.bonitasoft.studio.common,
org.bonitasoft.studio.common.diagram.palette,
org.bonitasoft.studio.common.diagram.tools,
org.bonitasoft.studio.common.editPolicies,
org.bonitasoft.studio.common.figures,
......
/**
* Copyright (C) 2012 BonitaSoft S.A.
* BonitaSoft, 32 rue Gustave Eiffel - 38000 Grenoble
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2.0 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.bonitasoft.studio.common.diagram.palette;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import org.eclipse.gef.internal.ui.palette.editparts.ToolEntryEditPart;
import org.eclipse.gef.palette.PaletteDrawer;
import org.eclipse.gef.palette.PaletteEntry;
import org.eclipse.gef.palette.PaletteListener;
import org.eclipse.gef.palette.PaletteRoot;
import org.eclipse.gef.palette.ToolEntry;
import org.eclipse.gmf.runtime.gef.ui.palette.customize.PaletteViewerEx;
import org.eclipse.jface.action.MenuManager;
/**
* @author Romain Bioteau
*
*/
public class CustomMainPaletteViewer extends PaletteViewerEx {
private Set<String> filters = new HashSet<String>();
private String onlyDisplayedEntry;
protected ToolEntry activeEntry = null;
private List paletteListeners = new ArrayList();
private CustomToolPaletteViewer toolPalette;
public CustomMainPaletteViewer(){
setEditPartFactory(new CustomPaletteEditPartFactory());
}
public void hidePaletteEntry(String id){
filters.add(id);
}
@Override
public void addPaletteListener(PaletteListener paletteListener) {
if (paletteListeners != null)
paletteListeners.add(paletteListener);
}
public void removePaletteListener(PaletteListener paletteListener) {
paletteListeners.remove(paletteListener);
}
@Override
public void setPaletteRoot(PaletteRoot root) {
if (root == getPaletteRoot())
return;
super.setPaletteRoot(root);
if (getPaletteRoot() != null) {
final PaletteRoot filteredPalette = filterPaletteRoot(getPaletteRoot());
for(Object c : filteredPalette.getChildren()){
if(c instanceof PaletteDrawer){
((PaletteDrawer)c).setShowDefaultIcon(false);
((PaletteDrawer)c).setUserModificationPermission(PaletteDrawer.PERMISSION_NO_MODIFICATION);
}
}
getRootEditPart().setContents(getEditPartFactory().createEditPart(
getRootEditPart(),filteredPalette));
}
}
@Override
public void setContextMenu(MenuManager contextMenu) {
}
public void setActiveTool(ToolEntry newMode) {
if (newMode == null)
newMode = getPaletteRoot().getDefaultEntry();
if(newMode.equals(activeEntry)){
return;
}
if (activeEntry != null){
final ToolEntryEditPart toolEntryEditPart = getToolEntryEditPart(activeEntry);
if(toolEntryEditPart != null){
toolEntryEditPart.setToolSelected(false);
}
}
activeEntry = newMode;
if (activeEntry != null) {
ToolEntryEditPart editpart = getToolEntryEditPart(activeEntry);
if (editpart != null) {
editpart.setToolSelected(true);
}
}
fireModeChanged();
if(toolPalette != null){
setEditDomain(toolPalette.getEditDomain());
toolPalette.setActiveTool(newMode);
}
}
/**
* @return the entry for the currently active tool
*/
public ToolEntry getActiveTool() {
return activeEntry;
}
protected void fireModeChanged() {
if (paletteListeners == null)
return;
for (int listener = 0; listener < paletteListeners.size(); listener++){
((PaletteListener) paletteListeners.get(listener)).activeToolChanged(this, activeEntry);
}
}
protected ToolEntryEditPart getToolEntryEditPart(ToolEntry entry) {
return (ToolEntryEditPart) getEditPartRegistry().get(entry);
}
private PaletteRoot filterPaletteRoot(PaletteRoot paletteRoot) {
PaletteRoot newRoot = new PaletteRoot();
for(Object child : paletteRoot.getChildren()){
if(child instanceof PaletteEntry){
final String id = ((PaletteEntry) child).getId();
if(onlyDisplayedEntry != null && onlyDisplayedEntry.equals(id)) {
newRoot.add((PaletteEntry) child);
break;
}else if(!filters.contains(id)){
newRoot.add((PaletteEntry) child);
}
}
}
return newRoot;
}
public void showOnlyPaletteEntry(String onlyDisplayedEntry) {
this.onlyDisplayedEntry = onlyDisplayedEntry;
}
public void setToolPaletteViewer(CustomToolPaletteViewer toolPalette) {
this.toolPalette = toolPalette;
}
}
/**
* Copyright (C) 2012 BonitaSoft S.A.
* BonitaSoft, 32 rue Gustave Eiffel - 38000 Grenoble
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2.0 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.bonitasoft.studio.common.diagram.palette;
import org.eclipse.draw2d.ColorConstants;
import org.eclipse.gef.EditPart;
import org.eclipse.gef.internal.ui.palette.editparts.ToolbarEditPart;
import org.eclipse.gef.ui.palette.PaletteEditPartFactory;
import org.eclipse.gmf.runtime.draw2d.ui.figures.FigureUtilities;
/**
* @author Romain Bioteau
*
*/
public class CustomPaletteEditPartFactory extends PaletteEditPartFactory{
@Override
protected EditPart createToolbarEditPart(EditPart parentEditPart,
Object model) {
ToolbarEditPart ep = (ToolbarEditPart) super.createToolbarEditPart(parentEditPart, model);
ep.getFigure().setBackgroundColor(FigureUtilities.lighter(ColorConstants.lightGray));
ep.getFigure().setOpaque(true);
return ep;
}
}
/**
* Copyright (C) 2012 BonitaSoft S.A.
* BonitaSoft, 32 rue Gustave Eiffel - 38000 Grenoble
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2.0 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.bonitasoft.studio.common.diagram.palette;
import java.beans.PropertyChangeListener;
import org.eclipse.gef.internal.ui.palette.editparts.ToolEntryEditPart;
import org.eclipse.gef.palette.ToolEntry;
import org.eclipse.gef.ui.palette.DefaultPaletteViewerPreferences;
import org.eclipse.gef.ui.palette.PaletteViewerPreferences;
import org.eclipse.swt.graphics.FontData;
/**
* @author Romain Bioteau
*
*/
public class CustomToolPaletteViewer extends CustomMainPaletteViewer {
private CustomMainPaletteViewer mainPalette;
public CustomToolPaletteViewer() {
super();
setPaletteViewerPreferences(new DefaultPaletteViewerPreferences() {
@Override
public boolean useLargeIcons(int layout) {
return true;
}
@Override
public boolean useLargeIcons() {
return true;
}
});
}
public void setActiveTool(ToolEntry newMode) {
if (newMode == null)
newMode = getPaletteRoot().getDefaultEntry();
if (activeEntry != null){
final ToolEntryEditPart toolEntryEditPart = getToolEntryEditPart(activeEntry);
if(toolEntryEditPart != null){
toolEntryEditPart.setToolSelected(false);
}
}
activeEntry = newMode;
if (activeEntry != null) {
ToolEntryEditPart editpart = getToolEntryEditPart(activeEntry);
if (editpart != null) {
editpart.setToolSelected(true);
}
}
fireModeChanged();
if(mainPalette != null){
mainPalette.setActiveTool(newMode);
}
}
public void setMainPaletteViewer(CustomMainPaletteViewer mainPalette) {
this.mainPalette = mainPalette;
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment