Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tkt 1610 change logo without restart #1723

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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 @@ -62,6 +62,9 @@ public void windowOpened(WindowEvent windowEvent) {
}
});
}
void replaceImagePanel(Image image){
myImagePanel.setIcon(new ImageIcon(image.getScaledInstance(-1, 50, Image.SCALE_DEFAULT)));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

any reason why the height must be 50px? There are calculations in the code below which take into account DPI setting. They probably shall not be ignored?

}

JComponent createContentComponent() {
JPanel tabContentPanel = new JPanel(new BorderLayout());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,10 @@ public class GanttProject extends GanttProjectBase implements ResourceView, Gant

private FXSearchUi mySearchUi;

public GanttChartTabContentPanel getGanttChartTabContent() {
return myGanttChartTabContent;
}

public GanttProject(boolean isOnlyViewer) {
System.err.println("Creating main frame...");
ToolTipManager.sharedInstance().setInitialDelay(200);
Expand Down
3 changes: 3 additions & 0 deletions ganttproject/src/net/sourceforge/ganttproject/GanttTree2.java
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,9 @@ public void selectionChanged(List<Task> currentSelection) {
myIndentAction, myUnindentAction, newAction, myProject.getCutAction(), myProject.getCopyAction(),
myProject.getPasteAction(), propertiesAction, deleteAction);
}
public GanttProject getMyProject() {
return myProject;
}

@Override
protected void init() {
Expand Down
30 changes: 18 additions & 12 deletions ganttproject/src/net/sourceforge/ganttproject/UIFacadeImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,18 +45,7 @@ of the License, or (at your option) any later version.
import net.sourceforge.ganttproject.chart.GanttChart;
import net.sourceforge.ganttproject.chart.TimelineChart;
import net.sourceforge.ganttproject.document.Document.DocumentException;
import net.sourceforge.ganttproject.gui.GanttLookAndFeelInfo;
import net.sourceforge.ganttproject.gui.GanttLookAndFeels;
import net.sourceforge.ganttproject.gui.GanttStatusBar;
import net.sourceforge.ganttproject.gui.NotificationChannel;
import net.sourceforge.ganttproject.gui.NotificationItem;
import net.sourceforge.ganttproject.gui.NotificationManager;
import net.sourceforge.ganttproject.gui.NotificationManagerImpl;
import net.sourceforge.ganttproject.gui.ResourceTreeUIFacade;
import net.sourceforge.ganttproject.gui.TaskSelectionContext;
import net.sourceforge.ganttproject.gui.TaskTreeUIFacade;
import net.sourceforge.ganttproject.gui.UIFacade;
import net.sourceforge.ganttproject.gui.ViewLogDialog;
import net.sourceforge.ganttproject.gui.*;
import net.sourceforge.ganttproject.gui.options.OptionsPageBuilder;
import net.sourceforge.ganttproject.gui.options.OptionsPageBuilder.I18N;
import net.sourceforge.ganttproject.gui.options.SettingsDialog2;
Expand Down Expand Up @@ -247,6 +236,23 @@ public void changeValue(ChangeValueEvent event) {
myOptions.setTitled(false);

myLogoOption = new DefaultFileOption("ui.logo");
myLogoOption.addChangeValueListener(new ChangeValueListener(){
@Override
public void changeValue(ChangeValueEvent event) {

if (event.getOldValue()!=null && event.getOldValue().equals(event.getNewValue())){
Image newLogo =getLogo();


((GanttTree2)myFallbackDelegate.getTaskTree()).
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think that we want to expose that many internal fields and do all these casts to concrete classes and call chains.
What about exposing LogoOption from UIFacade instead? Class ChartTabContentPanel has access to UIFacade instance, it will be able to get the logo option and add a listener.

getMyProject()
.getGanttChartTabContent().
replaceImagePanel(newLogo);
}

}
});

myLogoOptions = new GPOptionGroup("ui2", myLogoOption);
myLogoOptions.setTitled(false);
addOptions(myOptions);
Expand Down