diff options
author | Maged Elaasar | 2018-05-09 14:21:19 +0000 |
---|---|---|
committer | Benoit Maggi | 2018-06-20 08:50:30 +0000 |
commit | d64f2d709ce5d0eebc1fb520eafae6406b45ace8 (patch) | |
tree | 8218e70d79fabb57c958d9af1b27af26a2fd26cc /plugins/infra | |
parent | a634e9d9dcf04bd336e70fc588e0492ef04c036a (diff) | |
download | org.eclipse.papyrus-d64f2d709ce5d0eebc1fb520eafae6406b45ace8.tar.gz org.eclipse.papyrus-d64f2d709ce5d0eebc1fb520eafae6406b45ace8.tar.xz org.eclipse.papyrus-d64f2d709ce5d0eebc1fb520eafae6406b45ace8.zip |
Bug 528441 - [AFViewpoints][Palettes] Setting diagram prototype
programmatically does not refresh palettes of open diagrams
- Handle the listener case of no PapyrusDiagramStyle initially found on
the diagram
Change-Id: I32d93478bbf5a4fd10faad615afb5189e85dfc2b
Signed-off-by: Maged Elaasar <melaasar@gmail.com>
Diffstat (limited to 'plugins/infra')
-rw-r--r-- | plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/service/palette/PapyrusPaletteService.java | 74 |
1 files changed, 25 insertions, 49 deletions
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/service/palette/PapyrusPaletteService.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/service/palette/PapyrusPaletteService.java index 209b55f8b5c..e7a3a0a4a15 100644 --- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/service/palette/PapyrusPaletteService.java +++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/service/palette/PapyrusPaletteService.java @@ -227,17 +227,7 @@ public class PapyrusPaletteService extends PaletteService implements IPalettePro if (!(part instanceof DiagramEditorWithFlyOutPalette)) { return false; } - boolean supports = getProviderConfiguration().supports(o.getEditor(), o.getContent()); - - if (!supports) { - return false; - } - - if (isHidden(o)) { - return false; - } - - return true; + return getProviderConfiguration().supports(o.getEditor(), o.getContent()) && !isHidden(o); } return false; @@ -264,23 +254,8 @@ public class PapyrusPaletteService extends PaletteService implements IPalettePro return policy.provides(operation); } - // FIXME: that statement is always true (let's see the method's - // parameter). - // => Remove the test - if (operation instanceof ContributeToPaletteOperation) { - ContributeToPaletteOperation o = operation; - // FIXME returns directly the result - boolean supports = getProviderConfiguration().supports(o.getEditor(), o.getContent()); - - if (!supports) { - return false; - } - - return true; - } - - return false; + return getProviderConfiguration().supports(operation.getEditor(), operation.getContent()); } /** @@ -466,7 +441,6 @@ public class PapyrusPaletteService extends PaletteService implements IPalettePro filePath = filePath.substring(jarPathEndIndex + 2, path.length()); ZipEntry entry = zipFile.getEntry(path); return zipFile.getInputStream(entry); - // return new File(filePath); } } } catch (IOException e) { @@ -502,8 +476,7 @@ public class PapyrusPaletteService extends PaletteService implements IPalettePro Activator.log.error("Impossible to read local definition of the file " + stateLocationRootFile, null); return null; } - URI uri = URI.createFileURI(stateLocationRootFile.getAbsolutePath()); - return uri; + return URI.createFileURI(stateLocationRootFile.getAbsolutePath()); } } @@ -638,29 +611,21 @@ public class PapyrusPaletteService extends PaletteService implements IPalettePro if (!isEnable) { return false; } - // FIXME: that statement is always true (let's see the method's - // parameter). - // => Remove the test - if (operation instanceof ContributeToPaletteOperation) { - ContributeToPaletteOperation o = operation; - IEditorPart part = o.getEditor(); - if (!(part instanceof DiagramEditorWithFlyOutPalette)) { - return false; - } + IEditorPart part = operation.getEditor(); + if (!(part instanceof DiagramEditorWithFlyOutPalette)) { + return false; + } - // will never work, ID of the site is the multi diagram - // editor... - if (description.getContributionEditorID() != null) { - if (!description.getContributionEditorID().equals(((DiagramEditorWithFlyOutPalette) part).getContributorId())) { - return false; - } + // will never work, ID of the site is the multi diagram + // editor... + if (description.getContributionEditorID() != null) { + if (!description.getContributionEditorID().equals(((DiagramEditorWithFlyOutPalette) part).getContributorId())) { + return false; } - - return true; } - return false; + return true; } } @@ -944,9 +909,20 @@ public class PapyrusPaletteService extends PaletteService implements IPalettePro configurePaletteVisibility(checker, diagram, drawer); } } + + // if the default entry is set but not visible, set it to null instead to avoid a potential NPE + if (root.getDefaultEntry() != null && !isVisible(root.getDefaultEntry())) { + root.setDefaultEntry(null); + } + return root; } + private boolean isVisible(PaletteEntry entry) { + PaletteContainer parent = entry.getParent(); + return entry.isVisible() && (parent == null || isVisible(parent)); + } + protected void configurePaletteVisibility(PolicyChecker checker, Diagram diagram, PaletteContainer container) { boolean isVisible = checker.isInPalette(diagram, container.getId()); container.setVisible(isVisible); @@ -1047,7 +1023,7 @@ public class PapyrusPaletteService extends PaletteService implements IPalettePro // 2. inits the operation used to check if the provider really provides // to this service // 3. inits the list of ids of hidden palettes - List<PapyrusPaletteService.ProviderDescriptor> descriptors = new ArrayList<PapyrusPaletteService.ProviderDescriptor>(); + List<PapyrusPaletteService.ProviderDescriptor> descriptors = new ArrayList<>(); final ContributeToPaletteOperation o = new ContributeToPaletteOperation(part, part.getEditorInput(), root, new HashMap()); // For each provider, checks it contributes to the palette of this // editor part |