Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -41,18 +41,18 @@
*/
public final class DetailsPart implements IFormPart, IPartSelectionListener {
private IManagedForm managedForm;
private ScrolledPageBook pageBook;
private final ScrolledPageBook pageBook;
private IFormPart masterPart;
private IStructuredSelection currentSelection;
private Hashtable<Object, PageBag> pages;
private final Hashtable<Object, PageBag> pages;
private IDetailsPageProvider pageProvider;
private int pageLimit=Integer.MAX_VALUE;

private static class PageBag {
private static int counter;
private int ticket;
private final int ticket;
private IDetailsPage page;
private boolean fixed;
private final boolean fixed;

public PageBag(IDetailsPage page, boolean fixed) {
this.page= page;
Expand Down Expand Up @@ -127,8 +127,9 @@ public void setPageProvider(IDetailsPageProvider provider) {
@Override
public void commit(boolean onSave) {
IDetailsPage page = getCurrentPage();
if (page != null)
if (page != null) {
page.commit(onSave);
}
}
/**
* Returns the current page visible in the part.
Expand All @@ -138,8 +139,9 @@ public IDetailsPage getCurrentPage() {
Control control = pageBook.getCurrentPage();
if (control != null && !control.isDisposed()) {
Object data = control.getData();
if (data instanceof IDetailsPage)
if (data instanceof IDetailsPage) {
return (IDetailsPage) data;
}
}
return null;
}
Expand All @@ -163,8 +165,9 @@ public void initialize(IManagedForm form) {
@Override
public boolean isDirty() {
IDetailsPage page = getCurrentPage();
if (page != null)
if (page != null) {
return page.isDirty();
}
return false;
}
/**
Expand All @@ -174,8 +177,9 @@ public boolean isDirty() {
@Override
public boolean isStale() {
IDetailsPage page = getCurrentPage();
if (page != null)
if (page != null) {
return page.isStale();
}
return false;
}

Expand All @@ -185,17 +189,19 @@ public boolean isStale() {
@Override
public void refresh() {
IDetailsPage page = getCurrentPage();
if (page != null)
if (page != null) {
page.refresh();
}
}
/**
* Sets the focus to the currently visible page.
*/
@Override
public void setFocus() {
IDetailsPage page = getCurrentPage();
if (page != null)
if (page != null) {
page.setFocus();
}
}

@Override
Expand All @@ -208,19 +214,20 @@ public void selectionChanged(IFormPart part, ISelection selection) {
this.masterPart = part;
if (currentSelection != null) {
}
if (selection instanceof IStructuredSelection)
if (selection instanceof IStructuredSelection) {
currentSelection = (IStructuredSelection) selection;
else
} else {
currentSelection = null;
}
update();
}
private void update() {
Object key = null;
if (currentSelection != null) {
for (Object obj : currentSelection) {
if (key == null)
if (key == null) {
key = getKey(obj);
else if (!getKey(obj).equals(key)) {
} else if (!getKey(obj).equals(key)) {
key = null;
break;
}
Expand All @@ -231,8 +238,9 @@ else if (!getKey(obj).equals(key)) {
private Object getKey(Object object) {
if (pageProvider!=null) {
Object key = pageProvider.getPageKey(object);
if (key!=null)
if (key!=null) {
return key;
}
}
return object.getClass();
}
Expand Down Expand Up @@ -260,11 +268,13 @@ private void showPage(final Object key) {
parent.setData(fpage);
}
//commit the current page
if (oldPage!=null && oldPage.isDirty())
if (oldPage!=null && oldPage.isDirty()) {
oldPage.commit(false);
}
//refresh the new page
if (fpage.isStale())
if (fpage.isStale()) {
fpage.refresh();
}
fpage.selectionChanged(masterPart, currentSelection);
pageBook.showPage(key);
});
Expand All @@ -273,12 +283,15 @@ private void showPage(final Object key) {
}
// If we are switching from an old page to nothing,
// don't loose data
if (oldPage!=null && oldPage.isDirty())
if (oldPage!=null && oldPage.isDirty()) {
oldPage.commit(false);
}
pageBook.showEmptyPage();
}
private void checkLimit() {
if (pages.size() <= getPageLimit()) return;
if (pages.size() <= getPageLimit()) {
return;
}
// overflow
int currentTicket = PageBag.getCurrentTicket();
int cutoffTicket = currentTicket - getPageLimit();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,8 +175,9 @@ protected void initializeColorTable() {
* keys to ensure they are available.
*/
public void initializeSectionToolBarColors() {
if (colorRegistry.containsKey(IFormColors.TB_BG))
if (colorRegistry.containsKey(IFormColors.TB_BG)) {
return;
}
createTitleBarGradientColors();
createTitleBarOutlineColors();
createTwistieColors();
Expand All @@ -194,8 +195,9 @@ public void initializeSectionToolBarColors() {
* @since 3.3
*/
protected void initializeFormHeaderColors() {
if (colorRegistry.containsKey(IFormColors.H_BOTTOM_KEYLINE2))
if (colorRegistry.containsKey(IFormColors.H_BOTTOM_KEYLINE2)) {
return;
}
createFormHeaderColors();
}

Expand Down Expand Up @@ -226,8 +228,9 @@ public RGB getSystemColor(int code) {
public Color createColor(String key, RGB rgb) {
Color c = getResourceManager().createColor(rgb);
Color prevC = colorRegistry.get(key);
if (prevC != null && !prevC.isDisposed())
if (prevC != null && !prevC.isDisposed()) {
getResourceManager().destroyColor(prevC.getRGB());
}
colorRegistry.put(key, c);
return c;
}
Expand Down Expand Up @@ -282,15 +285,16 @@ public Color createColor(String key, int r, int g, int b) {
* background color will be used.
*/
protected void updateBorderColor() {
if (isWhiteBackground())
if (isWhiteBackground()) {
border = getColor(IFormColors.BORDER);
else {
} else {
border = display.getSystemColor(SWT.COLOR_WIDGET_BACKGROUND);
Color bg = getImpliedBackground();
if (border.getRed() == bg.getRed()
&& border.getGreen() == bg.getGreen()
&& border.getBlue() == bg.getBlue())
&& border.getBlue() == bg.getBlue()) {
border = display.getSystemColor(SWT.COLOR_WIDGET_DARK_SHADOW);
}
}
}

Expand Down Expand Up @@ -368,19 +372,21 @@ public boolean isWhiteBackground() {
* @return color object if found, or <samp>null </samp> if not.
*/
public Color getColor(String key) {
if (key.startsWith(IFormColors.TB_PREFIX))
if (key.startsWith(IFormColors.TB_PREFIX)) {
initializeSectionToolBarColors();
else if (key.startsWith(IFormColors.H_PREFIX))
} else if (key.startsWith(IFormColors.H_PREFIX)) {
initializeFormHeaderColors();
}
return colorRegistry.get(key);
}

/**
* Disposes all the colors in the registry.
*/
public void dispose() {
if (resources != null)
if (resources != null) {
resources.dispose();
}
resources = null;
colorRegistry = null;
}
Expand Down Expand Up @@ -436,12 +442,15 @@ public static RGB blend(RGB c1, RGB c2, int ratio) {
* @since 3.1
*/
public static boolean testAnyPrimaryColor(RGB rgb, int from, int to) {
if (testPrimaryColor(rgb.red, from, to))
if (testPrimaryColor(rgb.red, from, to)) {
return true;
if (testPrimaryColor(rgb.green, from, to))
}
if (testPrimaryColor(rgb.green, from, to)) {
return true;
if (testPrimaryColor(rgb.blue, from, to))
}
if (testPrimaryColor(rgb.blue, from, to)) {
return true;
}
return false;
}

Expand All @@ -461,12 +470,15 @@ public static boolean testAnyPrimaryColor(RGB rgb, int from, int to) {
*/
public static boolean testTwoPrimaryColors(RGB rgb, int from, int to) {
int total = 0;
if (testPrimaryColor(rgb.red, from, to))
if (testPrimaryColor(rgb.red, from, to)) {
total++;
if (testPrimaryColor(rgb.green, from, to))
}
if (testPrimaryColor(rgb.green, from, to)) {
total++;
if (testPrimaryColor(rgb.blue, from, to))
}
if (testPrimaryColor(rgb.blue, from, to)) {
total++;
}
return total >= 2;
}

Expand All @@ -487,8 +499,9 @@ private static int blend(int v1, int v2, int ratio) {
}

private Color getImpliedBackground() {
if (getBackground() != null)
if (getBackground() != null) {
return getBackground();
}
return getDisplay().getSystemColor(SWT.COLOR_WIDGET_BACKGROUND);
}

Expand Down Expand Up @@ -641,8 +654,9 @@ private void createFormHeaderDNDColors() {
}

private LocalResourceManager getResourceManager() {
if (resources == null)
if (resources == null) {
resources = new LocalResourceManager(JFaceResources.getResources());
}
return resources;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@
*/

public final class HyperlinkGroup extends HyperlinkSettings {
private ArrayList<Hyperlink> links = new ArrayList<>();
private final ArrayList<Hyperlink> links = new ArrayList<>();
private Hyperlink lastActivated;
private Hyperlink lastEntered;
private GroupListener listener;
private final GroupListener listener;
private boolean isActiveBackgroundSet;
private boolean isActiveForegroundSet;
private boolean isBackgroundSet;
Expand Down Expand Up @@ -69,22 +69,28 @@ private void onMouseEnter(Event e) {
Hyperlink link = (Hyperlink) e.widget;
previousBackground = link.getBackground();
previousForeground = link.getForeground();
if (isActiveBackgroundSet)
if (isActiveBackgroundSet) {
link.setBackground(getActiveBackground());
if (isActiveForegroundSet)
}
if (isActiveForegroundSet) {
link.setForeground(getActiveForeground());
if (getHyperlinkUnderlineMode() == UNDERLINE_HOVER)
}
if (getHyperlinkUnderlineMode() == UNDERLINE_HOVER) {
link.setUnderlined(true);
}
link.setCursor(getHyperlinkCursor());
}
private void onMouseExit(Event e) {
Hyperlink link = (Hyperlink) e.widget;
if (isActiveBackgroundSet)
if (isActiveBackgroundSet) {
link.setBackground(previousBackground);
if (isActiveForegroundSet)
}
if (isActiveForegroundSet) {
link.setForeground(previousForeground);
if (getHyperlinkUnderlineMode() == UNDERLINE_HOVER)
}
if (getHyperlinkUnderlineMode() == UNDERLINE_HOVER) {
link.setUnderlined(false);
}
}
@Override
public void linkActivated(HyperlinkEvent e) {
Expand All @@ -105,8 +111,9 @@ public void linkExited(HyperlinkEvent e) {
}
private void linkExited(Hyperlink link) {
link.setCursor(null);
if (lastEntered == link)
if (lastEntered == link) {
lastEntered = null;
}
}
}

Expand Down Expand Up @@ -139,12 +146,15 @@ public Hyperlink getLastActivated() {
*/

public void add(Hyperlink link) {
if (isBackgroundSet)
if (isBackgroundSet) {
link.setBackground(getBackground());
if (isForegroundSet)
}
if (isForegroundSet) {
link.setForeground(getForeground());
if (getHyperlinkUnderlineMode() == UNDERLINE_ALWAYS)
}
if (getHyperlinkUnderlineMode() == UNDERLINE_ALWAYS) {
link.setUnderlined(true);
}
hook(link);
}

Expand Down Expand Up @@ -237,16 +247,19 @@ private void unhook(Hyperlink link) {
link.removeHyperlinkListener(listener);
link.removeListener(SWT.MouseEnter, listener);
link.removeListener(SWT.MouseExit, listener);
if (lastActivated == link)
if (lastActivated == link) {
lastActivated = null;
if (lastEntered == link)
}
if (lastEntered == link) {
lastEntered = null;
}
links.remove(link);
}

private void onMouseDown(Event e) {
if (e.button == 1)
if (e.button == 1) {
return;
}
lastActivated = (Hyperlink) e.widget;
}
}
Loading
Loading