add flexible leads to some components through the menu

This commit is contained in:
bancika
2020-04-18 10:26:14 +02:00
parent f41a028236
commit f0219fce0b
14 changed files with 557 additions and 293 deletions
@@ -375,5 +375,12 @@ public interface IPlugInPort extends ISelectionProcessor, IMouseProcessor, IKeyP
/**
* @return size of extra space around the canvas
*/
double getExtraSpace();
double getExtraSpace();
/**
* Applies changes to the current project as specified by the provided {@link IProjectEditor}.
*
* @param editor
*/
void applyEditor(IProjectEditor editor);
}
@@ -0,0 +1,34 @@
/*
DIY Layout Creator (DIYLC).
Copyright (c) 2009-2018 held jointly by the individual authors.
This file is part of DIYLC.
DIYLC 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 3 of the License, or
(at your option) any later version.
DIYLC 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 DIYLC. If not, see <http://www.gnu.org/licenses/>.
*/
package org.diylc.common;
import java.util.Set;
import org.diylc.core.IDIYComponent;
import org.diylc.core.Project;
public interface IProjectEditor {
Set<IDIYComponent<?>> edit(Project project, Set<IDIYComponent<?>> selection);
String getEditAction();
}
@@ -66,6 +66,7 @@ import org.diylc.common.IKeyProcessor;
import org.diylc.common.INetlistAnalyzer;
import org.diylc.common.IPlugIn;
import org.diylc.common.IPlugInPort;
import org.diylc.common.IProjectEditor;
import org.diylc.common.PropertyWrapper;
import org.diylc.common.VariantPackage;
import org.diylc.core.ExpansionMode;
@@ -2288,6 +2289,29 @@ public class Presenter implements IPlugInPort {
drawingManager.fireZoomChanged();
}
}
@Override
public void applyEditor(IProjectEditor editor) {
LOG.debug(String.format("applyEditor(%s)", editor.getEditAction()));
Project oldProject = currentProject.clone();
try {
Set<IDIYComponent<?>> newSelection = editor.edit(currentProject, selectedComponents);
if (newSelection != null)
updateSelection(newSelection);
} catch (Exception e) {
LOG.error("Could not apply editor", e);
view.showMessage("Could not apply " + editor.getEditAction() + ". Check the log for details.", "Error", IView.ERROR_MESSAGE);
} finally {
// Notify the listeners.
if (!oldProject.equals(currentProject)) {
messageDispatcher.dispatchMessage(EventType.PROJECT_MODIFIED, oldProject, currentProject.clone(),
editor.getEditAction());
drawingManager.clearContinuityArea();
projectFileManager.notifyFileChange();
}
drawingManager.fireZoomChanged();
}
}
@Override
public ComponentType getNewComponentTypeSlot() {