Diff
checker
टेक्स्ट
टेक्स्ट
छवियां
दस्तावेज़
Excel
फ़ोल्डर्स
Legal
Enterprise
डेस्कटॉप
मूल्य
साइन इन करें
Diffchecker डेस्कटॉप डाउनलोड करें
टेक्स्ट की तुलना करें
दो टेक्स्ट फ़ाइलों के बीच अंतर ढूंढें
उपकरण
इतिहास
रियल-टाइम एडिटर
अपरिवर्तित संक्षिप्त करें
लाइन रैप बंद
लेआउट
विभाजित
संयुक्त
परिवर्तन हाइलाइट करें
स्मार्ट
शब्द
अक्षर
सिंटैक्स हाइलाइटिंग
सिंटैक्स चुनें
अनदेखा करें
टेक्स्ट बदलें
पहले अंतर पर जाएँ
इनपुट संपादित करें
Diffchecker Desktop
Diffchecker चलाने का सबसे सुरक्षित तरीका। Diffchecker Desktop ऐप पाएं: आपके diffs कभी आपके कंप्यूटर से बाहर नहीं जाते!
Desktop पाएं
AbstractAction.java
बनाया गया
7 वर्ष पहले
Diff कभी समाप्त नहीं होता
साफ़
निर्यात करें
शेयर करें
समझाएं
41 हटाए गए
लाइनें
कुल
हटाया गया
अक्षर
कुल
हटाया गया
इस सुविधा का उपयोग जारी रखने के लिए, अपग्रेड करें
Diff
checker
Pro
मूल्य देखें
253 लाइनें
सभी को कॉपी करें
76 जोड़े गए
लाइनें
कुल
जोड़ा गया
अक्षर
कुल
जोड़ा गया
इस सुविधा का उपयोग जारी रखने के लिए, अपग्रेड करें
Diff
checker
Pro
मूल्य देखें
295 लाइनें
सभी को कॉपी करें
/*
/*
* Copyright (c) 2008-2016 Haulmont.
* Copyright (c) 2008-2016 Haulmont.
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing, software
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* See the License for the specific language governing permissions and
* limitations under the License.
* limitations under the License.
*
*
*/
*/
package com.haulmont.cuba.gui.components;
package com.haulmont.cuba.gui.components;
कॉपी
कॉपी हुआ
कॉपी
कॉपी हुआ
import com.google.common.collect.Collections2;
import com.google.common.collect.ImmutableList;
import com.haulmont.bali.events.EventHub;
import com.haulmont.cuba.core.global.AppBeans;
import com.haulmont.cuba.core.global.AppBeans;
import com.haulmont.cuba.core.global.Messages;
import com.haulmont.cuba.core.global.Messages;
कॉपी
कॉपी हुआ
कॉपी
कॉपी हुआ
import com.haulmont.cuba.core.global.UserSessionSource;
import com.haulmont.cuba.gui.icons.Icons;
import com.haulmont.cuba.gui.icons.Icons;
कॉपी
कॉपी हुआ
कॉपी
कॉपी हुआ
import com.haulmont.cuba.security.global.UserSession;
import javax.annotation.Nullable;
import javax.annotation.Nullable;
कॉपी
कॉपी हुआ
कॉपी
कॉपी हुआ
import java.beans.PropertyChange
Listener
;
import java.beans.PropertyChange
Event
;
import java.
beans.PropertyChangeSupport
;
import java.
util.Collection;
import java.util.
*
;
import java.util.List;
import java.util.Objects
;
import java.util.
function.Consumer
;
/**
/**
* Abstract class for GUI actions.
* Abstract class for GUI actions.
*/
*/
public abstract class AbstractAction implements Action {
public abstract class AbstractAction implements Action {
protected String id;
protected String id;
protected String caption;
protected String caption;
कॉपी
कॉपी हुआ
कॉपी
कॉपी हुआ
protected String description;
protected String description;
कॉपी
कॉपी हुआ
कॉपी
कॉपी हुआ
protected String icon;
protected String icon;
protected boolean enabled = true;
protected boolean enabled = true;
कॉपी
कॉपी हुआ
कॉपी
कॉपी हुआ
protected boolean visible = true;
protected boolean visible = true;
कॉपी
कॉपी हुआ
कॉपी
कॉपी हुआ
protected List<
Component.
ActionOwner> owners =
new ArrayList<>();
protected List<
ActionOwner> owners =
ImmutableList.of();
protected PropertyChangeSupport changeSupport;
protected Messages messages = AppBeans.get(Messages.NAME);
protected UserSession userSession;
protected KeyCombination shortcut;
protected KeyCombination shortcut;
protected boolean primary = false;
protected boolean primary = false;
कॉपी
कॉपी हुआ
कॉपी
कॉपी हुआ
protected EventHub eventHub;
// legacy field
@Deprecated
private Messages messages;
protected AbstractAction() {
// do not init messages here
}
protected AbstractAction(String id) {
protected AbstractAction(String id) {
कॉपी
कॉपी हुआ
कॉपी
कॉपी हुआ
UserSessionSource sessionSource = AppBeans.get(UserSessionSource.NAME);
userSession = sessionSource.getUserSession();
this.id = id;
this.id = id;
कॉपी
कॉपी हुआ
कॉपी
कॉपी हुआ
this.messages = AppBeans.get(Messages.NAME); // legacy behaviour
}
}
protected AbstractAction(String id, @Nullable String shortcut) {
protected AbstractAction(String id, @Nullable String shortcut) {
this(id);
this(id);
if (shortcut != null) {
if (shortcut != null) {
this.shortcut = KeyCombination.create(shortcut);
this.shortcut = KeyCombination.create(shortcut);
}
}
}
}
protected AbstractAction(String id, Status status) {
protected AbstractAction(String id, Status status) {
this(id);
this(id);
this.primary = status == Status.PRIMARY;
this.primary = status == Status.PRIMARY;
}
}
कॉपी
कॉपी हुआ
कॉपी
कॉपी हुआ
// lazy initializer
protected EventHub getEventHub() {
if (eventHub == null) {
eventHub = new EventHub();
}
return eventHub;
}
protected boolean hasSubscriptions(Class<?> eventClass) {
return eventHub != null && eventHub.hasSubscriptions(eventClass);
}
@Override
@Override
public String getId() {
public String getId() {
return id;
return id;
}
}
@Override
@Override
public String getCaption() {
public String getCaption() {
return caption == null ? getDefaultCaption() : caption;
return caption == null ? getDefaultCaption() : caption;
}
}
protected String getDefaultCaption() {
protected String getDefaultCaption() {
कॉपी
कॉपी हुआ
कॉपी
कॉपी हुआ
return messages.getMessage(getClass(), id);
if (messages != null) {
// legacy behaviour
return messages.getMessage(getClass(), id);
} else {
return null;
}
}
}
@Override
@Override
public void setCaption(String caption) {
public void setCaption(String caption) {
String oldValue = this.caption;
String oldValue = this.caption;
if (!Objects.equals(oldValue, caption)) {
if (!Objects.equals(oldValue, caption)) {
this.caption = caption;
this.caption = caption;
firePropertyChange(PROP_CAPTION, oldValue, caption);
firePropertyChange(PROP_CAPTION, oldValue, caption);
}
}
}
}
@Override
@Override
public String getDescription() {
public String getDescription() {
return description;
return description;
}
}
@Override
@Override
public void setDescription(String description) {
public void setDescription(String description) {
String oldValue = this.description;
String oldValue = this.description;
if (!Objects.equals(oldValue, description)) {
if (!Objects.equals(oldValue, description)) {
this.description = description;
this.description = description;
firePropertyChange(PROP_DESCRIPTION, oldValue, description);
firePropertyChange(PROP_DESCRIPTION, oldValue, description);
}
}
}
}
@Override
@Override
public KeyCombination getShortcutCombination() {
public KeyCombination getShortcutCombination() {
return shortcut;
return shortcut;
}
}
@Override
@Override
public void setShortcutCombination(KeyCombination shortcut) {
public void setShortcutCombination(KeyCombination shortcut) {
KeyCombination oldValue = this.shortcut;
KeyCombination oldValue = this.shortcut;
if (!Objects.equals(oldValue, shortcut)) {
if (!Objects.equals(oldValue, shortcut)) {
this.shortcut = shortcut;
this.shortcut = shortcut;
firePropertyChange(PROP_SHORTCUT, oldValue, shortcut);
firePropertyChange(PROP_SHORTCUT, oldValue, shortcut);
}
}
}
}
@Override
@Override
public void setShortcut(String shortcut) {
public void setShortcut(String shortcut) {
if (shortcut != null) {
if (shortcut != null) {
setShortcutCombination(KeyCombination.create(shortcut));
setShortcutCombination(KeyCombination.create(shortcut));
} else {
} else {
setShortcutCombination(null);
setShortcutCombination(null);
}
}
}
}
@Override
@Override
public String getIcon() {
public String getIcon() {
return icon;
return icon;
}
}
@Override
@Override
public void setIcon(String icon) {
public void setIcon(String icon) {
String oldValue = this.icon;
String oldValue = this.icon;
if (!Objects.equals(oldValue, icon)) {
if (!Objects.equals(oldValue, icon)) {
this.icon = icon;
this.icon = icon;
firePropertyChange(PROP_ICON, oldValue, icon);
firePropertyChange(PROP_ICON, oldValue, icon);
}
}
}
}
@Override
@Override
public void setIconFromSet(Icons.Icon icon) {
public void setIconFromSet(Icons.Icon icon) {
String iconName = AppBeans.get(Icons.class)
String iconName = AppBeans.get(Icons.class)
.get(icon);
.get(icon);
setIcon(iconName);
setIcon(iconName);
}
}
@Override
@Override
public boolean isEnabled() {
public boolean isEnabled() {
return enabled;
return enabled;
}
}
@Override
@Override
public void setEnabled(boolean enabled) {
public void setEnabled(boolean enabled) {
boolean oldValue = this.enabled;
boolean oldValue = this.enabled;
if (oldValue != enabled) {
if (oldValue != enabled) {
this.enabled = enabled;
this.enabled = enabled;
कॉपी
कॉपी हुआ
कॉपी
कॉपी हुआ
for (
Component.
ActionOwner owner : owners) {
for (
ActionOwner owner : owners) {
if (
owner != null &&
owner instanceof Component) {
if (
owner instanceof Component) {
((Component) owner).setEnabled(enabled);
((Component) owner).setEnabled(enabled);
}
}
}
}
firePropertyChange(PROP_ENABLED, oldValue, enabled);
firePropertyChange(PROP_ENABLED, oldValue, enabled);
}
}
}
}
@Override
@Override
public boolean isVisible() {
public boolean isVisible() {
return visible;
return visible;
}
}
@Override
@Override
public void setVisible(boolean visible) {
public void setVisible(boolean visible) {
boolean oldValue = this.visible;
boolean oldValue = this.visible;
if (oldValue != visible) {
if (oldValue != visible) {
this.visible = visible;
this.visible = visible;
कॉपी
कॉपी हुआ
कॉपी
कॉपी हुआ
for (
Component.
ActionOwner owner : owners) {
for (
ActionOwner owner : owners) {
if (
owner != null &&
owner instanceof Component) {
if (
owner instanceof Component) {
((Component) owner).setVisible(visible);
((Component) owner).setVisible(visible);
}
}
}
}
firePropertyChange(PROP_VISIBLE, oldValue, visible);
firePropertyChange(PROP_VISIBLE, oldValue, visible);
}
}
}
}
@Override
@Override
कॉपी
कॉपी हुआ
कॉपी
कॉपी हुआ
public Collection<
Component.
ActionOwner> getOwners() {
public Collection<
ActionOwner> getOwners() {
return
Collections.unmodifiableCollection(
owners
)
;
return
owners
;
}
}
@Override
@Override
कॉपी
कॉपी हुआ
कॉपी
कॉपी हुआ
public
Component.
ActionOwner getOwner() {
public
ActionOwner getOwner() {
return owners.isEmpty() ? null : owners.get(0);
return owners.isEmpty() ? null : owners.get(0);
}
}
@Override
@Override
कॉपी
कॉपी हुआ
कॉपी
कॉपी हुआ
public void addOwner(
Component.
ActionOwner actionOwner) {
public void addOwner(
ActionOwner actionOwner) {
if (!owners.contains(actionOwner)) {
if (!owners.contains(actionOwner)) {
कॉपी
कॉपी हुआ
कॉपी
कॉपी हुआ
owners.add(actionOwner);
if (owners.isEmpty()) {
owners = ImmutableList.of(actionOwner);
} else {
owners = ImmutableList.<ActionOwner>builder()
.addAll(owners)
.add(actionOwner)
.build();
}
}
}
}
}
@Override
@Override
कॉपी
कॉपी हुआ
कॉपी
कॉपी हुआ
public void removeOwner(
Component.
ActionOwner actionOwner) {
public void removeOwner(
ActionOwner actionOwner) {
owners.remove(actionOwner);
if (!owners.isEmpty()) {
if (owners.size() == 1 && owners.get(0) == actionOwner) {
owners = ImmutableList.of();
} else {
owners = ImmutableList.<ActionOwner>builder()
.addAll(Collections2.filter(owners, o -> o != actionOwner))
.build();
}
}
}
}
@Override
@Override
कॉपी
कॉपी हुआ
कॉपी
कॉपी हुआ
public void addPropertyChangeListener(
PropertyChange
Listener
listener) {
public void addPropertyChangeListener(
Consumer<
PropertyChange
Event>
listener) {
if (changeSupport == null) {
getEventHub().subscribe(PropertyChangeEvent.class,
listener);
changeSupport = new PropertyChangeSupport(this);
}
changeSupport.addPropertyChangeListener(
listener);
}
}
@Override
@Override
कॉपी
कॉपी हुआ
कॉपी
कॉपी हुआ
public void removePropertyChangeListener(
PropertyChange
Listener
listener) {
public void removePropertyChangeListener(
Consumer<
PropertyChange
Event>
listener) {
if (
changeSupport =
= null) {
if (
eventHub !
= null) {
return
;
eventHub.unsubscribe(PropertyChangeEvent.class, listener)
;
}
}
कॉपी
कॉपी हुआ
कॉपी
कॉपी हुआ
changeSupport.removePropertyChangeListener(listener);
}
}
protected void firePropertyChange(String propertyName, Object oldValue, Object newValue) {
protected void firePropertyChange(String propertyName, Object oldValue, Object newValue) {
कॉपी
कॉपी हुआ
कॉपी
कॉपी हुआ
if (
changeSupport == null ||
Objects.equals(oldValue, newValue)) {
if (
Objects.equals(oldValue, newValue)) {
return;
return;
}
}
कॉपी
कॉपी हुआ
कॉपी
कॉपी हुआ
changeSupport.firePropertyChange(
propertyName, oldValue, newValue);
if (eventHub != null && eventHub.hasSubscriptions(PropertyChangeEvent.class)) {
PropertyChangeEvent event = new PropertyChangeEvent(this,
propertyName, oldValue, newValue);
eventHub.publish(PropertyChangeEvent.class, event);
}
}
}
@Override
@Override
public void refreshState() {
public void refreshState() {
}
}
कॉपी
कॉपी हुआ
कॉपी
कॉपी हुआ
/**
* @return true if action is primary or false otherwise
*/
public boolean isPrimary() {
public boolean isPrimary() {
return primary;
return primary;
}
}
कॉपी
कॉपी हुआ
कॉपी
कॉपी हुआ
/**
* Sets whether action is primary or not.
*
* @param primary primary
*/
public void setPrimary(boolean primary) {
public void setPrimary(boolean primary) {
this.primary = primary;
this.primary = primary;
}
}
}
}
सेव किए गए Diffs
ऑरिजनल टेक्स्ट
फ़ाइल खोलें
/* * Copyright (c) 2008-2016 Haulmont. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ package com.haulmont.cuba.gui.components; import com.haulmont.cuba.core.global.AppBeans; import com.haulmont.cuba.core.global.Messages; import com.haulmont.cuba.core.global.UserSessionSource; import com.haulmont.cuba.gui.icons.Icons; import com.haulmont.cuba.security.global.UserSession; import javax.annotation.Nullable; import java.beans.PropertyChangeListener; import java.beans.PropertyChangeSupport; import java.util.*; /** * Abstract class for GUI actions. */ public abstract class AbstractAction implements Action { protected String id; protected String caption; protected String description; protected String icon; protected boolean enabled = true; protected boolean visible = true; protected List<Component.ActionOwner> owners = new ArrayList<>(); protected PropertyChangeSupport changeSupport; protected Messages messages = AppBeans.get(Messages.NAME); protected UserSession userSession; protected KeyCombination shortcut; protected boolean primary = false; protected AbstractAction(String id) { UserSessionSource sessionSource = AppBeans.get(UserSessionSource.NAME); userSession = sessionSource.getUserSession(); this.id = id; } protected AbstractAction(String id, @Nullable String shortcut) { this(id); if (shortcut != null) { this.shortcut = KeyCombination.create(shortcut); } } protected AbstractAction(String id, Status status) { this(id); this.primary = status == Status.PRIMARY; } @Override public String getId() { return id; } @Override public String getCaption() { return caption == null ? getDefaultCaption() : caption; } protected String getDefaultCaption() { return messages.getMessage(getClass(), id); } @Override public void setCaption(String caption) { String oldValue = this.caption; if (!Objects.equals(oldValue, caption)) { this.caption = caption; firePropertyChange(PROP_CAPTION, oldValue, caption); } } @Override public String getDescription() { return description; } @Override public void setDescription(String description) { String oldValue = this.description; if (!Objects.equals(oldValue, description)) { this.description = description; firePropertyChange(PROP_DESCRIPTION, oldValue, description); } } @Override public KeyCombination getShortcutCombination() { return shortcut; } @Override public void setShortcutCombination(KeyCombination shortcut) { KeyCombination oldValue = this.shortcut; if (!Objects.equals(oldValue, shortcut)) { this.shortcut = shortcut; firePropertyChange(PROP_SHORTCUT, oldValue, shortcut); } } @Override public void setShortcut(String shortcut) { if (shortcut != null) { setShortcutCombination(KeyCombination.create(shortcut)); } else { setShortcutCombination(null); } } @Override public String getIcon() { return icon; } @Override public void setIcon(String icon) { String oldValue = this.icon; if (!Objects.equals(oldValue, icon)) { this.icon = icon; firePropertyChange(PROP_ICON, oldValue, icon); } } @Override public void setIconFromSet(Icons.Icon icon) { String iconName = AppBeans.get(Icons.class) .get(icon); setIcon(iconName); } @Override public boolean isEnabled() { return enabled; } @Override public void setEnabled(boolean enabled) { boolean oldValue = this.enabled; if (oldValue != enabled) { this.enabled = enabled; for (Component.ActionOwner owner : owners) { if (owner != null && owner instanceof Component) { ((Component) owner).setEnabled(enabled); } } firePropertyChange(PROP_ENABLED, oldValue, enabled); } } @Override public boolean isVisible() { return visible; } @Override public void setVisible(boolean visible) { boolean oldValue = this.visible; if (oldValue != visible) { this.visible = visible; for (Component.ActionOwner owner : owners) { if (owner != null && owner instanceof Component) { ((Component) owner).setVisible(visible); } } firePropertyChange(PROP_VISIBLE, oldValue, visible); } } @Override public Collection<Component.ActionOwner> getOwners() { return Collections.unmodifiableCollection(owners); } @Override public Component.ActionOwner getOwner() { return owners.isEmpty() ? null : owners.get(0); } @Override public void addOwner(Component.ActionOwner actionOwner) { if (!owners.contains(actionOwner)) { owners.add(actionOwner); } } @Override public void removeOwner(Component.ActionOwner actionOwner) { owners.remove(actionOwner); } @Override public void addPropertyChangeListener(PropertyChangeListener listener) { if (changeSupport == null) { changeSupport = new PropertyChangeSupport(this); } changeSupport.addPropertyChangeListener(listener); } @Override public void removePropertyChangeListener(PropertyChangeListener listener) { if (changeSupport == null) { return; } changeSupport.removePropertyChangeListener(listener); } protected void firePropertyChange(String propertyName, Object oldValue, Object newValue) { if (changeSupport == null || Objects.equals(oldValue, newValue)) { return; } changeSupport.firePropertyChange(propertyName, oldValue, newValue); } @Override public void refreshState() { } public boolean isPrimary() { return primary; } public void setPrimary(boolean primary) { this.primary = primary; } }
परिवर्तित टेक्स्ट
फ़ाइल खोलें
/* * Copyright (c) 2008-2016 Haulmont. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ package com.haulmont.cuba.gui.components; import com.google.common.collect.Collections2; import com.google.common.collect.ImmutableList; import com.haulmont.bali.events.EventHub; import com.haulmont.cuba.core.global.AppBeans; import com.haulmont.cuba.core.global.Messages; import com.haulmont.cuba.gui.icons.Icons; import javax.annotation.Nullable; import java.beans.PropertyChangeEvent; import java.util.Collection; import java.util.List; import java.util.Objects; import java.util.function.Consumer; /** * Abstract class for GUI actions. */ public abstract class AbstractAction implements Action { protected String id; protected String caption; protected String description; protected String icon; protected boolean enabled = true; protected boolean visible = true; protected List<ActionOwner> owners = ImmutableList.of(); protected KeyCombination shortcut; protected boolean primary = false; protected EventHub eventHub; // legacy field @Deprecated private Messages messages; protected AbstractAction() { // do not init messages here } protected AbstractAction(String id) { this.id = id; this.messages = AppBeans.get(Messages.NAME); // legacy behaviour } protected AbstractAction(String id, @Nullable String shortcut) { this(id); if (shortcut != null) { this.shortcut = KeyCombination.create(shortcut); } } protected AbstractAction(String id, Status status) { this(id); this.primary = status == Status.PRIMARY; } // lazy initializer protected EventHub getEventHub() { if (eventHub == null) { eventHub = new EventHub(); } return eventHub; } protected boolean hasSubscriptions(Class<?> eventClass) { return eventHub != null && eventHub.hasSubscriptions(eventClass); } @Override public String getId() { return id; } @Override public String getCaption() { return caption == null ? getDefaultCaption() : caption; } protected String getDefaultCaption() { if (messages != null) { // legacy behaviour return messages.getMessage(getClass(), id); } else { return null; } } @Override public void setCaption(String caption) { String oldValue = this.caption; if (!Objects.equals(oldValue, caption)) { this.caption = caption; firePropertyChange(PROP_CAPTION, oldValue, caption); } } @Override public String getDescription() { return description; } @Override public void setDescription(String description) { String oldValue = this.description; if (!Objects.equals(oldValue, description)) { this.description = description; firePropertyChange(PROP_DESCRIPTION, oldValue, description); } } @Override public KeyCombination getShortcutCombination() { return shortcut; } @Override public void setShortcutCombination(KeyCombination shortcut) { KeyCombination oldValue = this.shortcut; if (!Objects.equals(oldValue, shortcut)) { this.shortcut = shortcut; firePropertyChange(PROP_SHORTCUT, oldValue, shortcut); } } @Override public void setShortcut(String shortcut) { if (shortcut != null) { setShortcutCombination(KeyCombination.create(shortcut)); } else { setShortcutCombination(null); } } @Override public String getIcon() { return icon; } @Override public void setIcon(String icon) { String oldValue = this.icon; if (!Objects.equals(oldValue, icon)) { this.icon = icon; firePropertyChange(PROP_ICON, oldValue, icon); } } @Override public void setIconFromSet(Icons.Icon icon) { String iconName = AppBeans.get(Icons.class) .get(icon); setIcon(iconName); } @Override public boolean isEnabled() { return enabled; } @Override public void setEnabled(boolean enabled) { boolean oldValue = this.enabled; if (oldValue != enabled) { this.enabled = enabled; for (ActionOwner owner : owners) { if (owner instanceof Component) { ((Component) owner).setEnabled(enabled); } } firePropertyChange(PROP_ENABLED, oldValue, enabled); } } @Override public boolean isVisible() { return visible; } @Override public void setVisible(boolean visible) { boolean oldValue = this.visible; if (oldValue != visible) { this.visible = visible; for (ActionOwner owner : owners) { if (owner instanceof Component) { ((Component) owner).setVisible(visible); } } firePropertyChange(PROP_VISIBLE, oldValue, visible); } } @Override public Collection<ActionOwner> getOwners() { return owners; } @Override public ActionOwner getOwner() { return owners.isEmpty() ? null : owners.get(0); } @Override public void addOwner(ActionOwner actionOwner) { if (!owners.contains(actionOwner)) { if (owners.isEmpty()) { owners = ImmutableList.of(actionOwner); } else { owners = ImmutableList.<ActionOwner>builder() .addAll(owners) .add(actionOwner) .build(); } } } @Override public void removeOwner(ActionOwner actionOwner) { if (!owners.isEmpty()) { if (owners.size() == 1 && owners.get(0) == actionOwner) { owners = ImmutableList.of(); } else { owners = ImmutableList.<ActionOwner>builder() .addAll(Collections2.filter(owners, o -> o != actionOwner)) .build(); } } } @Override public void addPropertyChangeListener(Consumer<PropertyChangeEvent> listener) { getEventHub().subscribe(PropertyChangeEvent.class, listener); } @Override public void removePropertyChangeListener(Consumer<PropertyChangeEvent> listener) { if (eventHub != null) { eventHub.unsubscribe(PropertyChangeEvent.class, listener); } } protected void firePropertyChange(String propertyName, Object oldValue, Object newValue) { if (Objects.equals(oldValue, newValue)) { return; } if (eventHub != null && eventHub.hasSubscriptions(PropertyChangeEvent.class)) { PropertyChangeEvent event = new PropertyChangeEvent(this, propertyName, oldValue, newValue); eventHub.publish(PropertyChangeEvent.class, event); } } @Override public void refreshState() { } /** * @return true if action is primary or false otherwise */ public boolean isPrimary() { return primary; } /** * Sets whether action is primary or not. * * @param primary primary */ public void setPrimary(boolean primary) { this.primary = primary; } }
अंतर खोजें